Is there a way to expand a String field with quoted JSON into a document

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Is there a way to expand a String field with quoted JSON into a document

Jose Malheiro
Hi,

I have a JSON message similar to this:

{
   
"methodName": "getDigitalId()",
   
"host": "localhost",
   
"threadName": "960894892@qtp-699536522-6(355)",
   
"requestData": [
     
"{\"data\":{\"requestContext\":{\"messageTraceId\":null,\"senderId\":null,\"applicationSessionId\":null},\"userId\":\"username\",\"uuid\":0}}"
   
],
   
"responseData": "{\"data\":{\"requestContext\":null,\"digitalIdEbo\":{\"id\":935,\"username\":\"[hidden email]\",\"password\":\"5AED6242E91AEA045306CDA531121FF966DB321F\"}}}",
   
"eventLocation": "ADAPTOR",
   
"applicationSessionId": "dwifj334uhdgfff",
   
"applicationVersion": "NOT_SUPPLIED"
}


I would like to expand the requestData and responseData field as part of the document when I insert it into elasticsearch.

Is there a mapping for such type - i.e. expand the quoted JSON string and merge it into the JSON document?

The result document should look something like:

{
   
"methodName": "getDigitalId()",
   
"host": "localhost",
   
"threadName": "960894892@qtp-699536522-6(355)",
   
"requestData": [
     
{
         
"data": {
           
"requestContext": {
               
"messageTraceId": null,
               
"senderId": null,
               
"applicationSessionId": null
           
},
           
"userId": "username",
           
"uuid": 0
         
}
     
}
   
],
   
"responseData": {
     
"data": {
         
"requestContext": null,
         
"digitalIdEbo": {
           
"id": 935,
           
"username": "[hidden email]",
           
"password": "5AED6242E91AEA045306CDA531121FF966DB321F"
         
}
     
}
   
},
   
"eventLocation": "ADAPTOR",
   
"applicationSessionId": "dwifj334uhdgfff",
   
"applicationVersion": "NOT_SUPPLIED"
}

thanking you in advance.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: Is there a way to expand a String field with quoted JSON into a document

ppearcy
Nothing I know of like this exists, but should be easy to do if you are working in Java with the Jackson API. I'd think any other framework/language you are working in would have similar facilities to parse JSON. 

Best Regards,
Paul

On Friday, November 22, 2013 4:29:46 PM UTC-5, Jose Malheiro wrote:
Hi,

I have a JSON message similar to this:

{
   
"methodName": "getDigitalId()",
   
"host": "localhost",
   
"threadName": "960894892@qtp-699536522-6(355)",
   
"requestData": [
     
"{\"data\":{\"requestContext\":{\"messageTraceId\":null,\"senderId\":null,\"applicationSessionId\":null},\"userId\":\"username\",\"uuid\":0}}"
   
],
   
"responseData": "{\"data\":{\"requestContext\":null,\"digitalIdEbo\":{\"id\":935,\"username\":\"<a href="javascript:" target="_blank" gdf-obfuscated-mailto="tKTYHiTzIzYJ" _originalhref="javascript:">bl...@some.com\",\"password\":\"5AED6242E91AEA045306CDA531121FF966DB321F\"}}}",
   
"eventLocation": "ADAPTOR",
   
"applicationSessionId": "dwifj334uhdgfff",
   
"applicationVersion": "NOT_SUPPLIED"
}


I would like to expand the requestData and responseData field as part of the document when I insert it into elasticsearch.

Is there a mapping for such type - i.e. expand the quoted JSON string and merge it into the JSON document?

The result document should look something like:

{
   
"methodName": "getDigitalId()",
   
"host": "localhost",
   
"threadName": "960894892@qtp-699536522-6(355)",
   
"requestData": [
     
{
         
"data": {
           
"requestContext": {
               
"messageTraceId": null,
               
"senderId": null,
               
"applicationSessionId": null
           
},
           
"userId": "username",
           
"uuid": 0
         
}
     
}
   
],
   
"responseData": {
     
"data": {
         
"requestContext": null,
         
"digitalIdEbo": {
           
"id": 935,
           
"username": "<a href="javascript:" target="_blank" gdf-obfuscated-mailto="tKTYHiTzIzYJ" _originalhref="javascript:">bl...@...",
           
"password": "5AED6242E91AEA045306CDA531121FF966DB321F"
         
}
     
}
   
},
   
"eventLocation": "ADAPTOR",
   
"applicationSessionId": "dwifj334uhdgfff",
   
"applicationVersion": "NOT_SUPPLIED"
}

thanking you in advance.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: Is there a way to expand a String field with quoted JSON into a document

Jose Malheiro
Thanks Paul, but unfortunately I don't have access to the source message - would've been great to have a mapping that would 'automagically' do this when adding a document.

What I may have to do is parse the JSON first and then convert the String to JSON for those fields.

cheers, Jose.

On Monday, 25 November 2013 21:55:13 UTC+2, ppearcy wrote:
Nothing I know of like this exists, but should be easy to do if you are working in Java with the Jackson API. I'd think any other framework/language you are working in would have similar facilities to parse JSON. 

Best Regards,
Paul

On Friday, November 22, 2013 4:29:46 PM UTC-5, Jose Malheiro wrote:
Hi,

I have a JSON message similar to this:

{
   
"methodName": "getDigitalId()",
   
"host": "localhost",
   
"threadName": "960894892@qtp-699536522-6(355)",
   
"requestData": [
     
"{\"data\":{\"requestContext\":{\"messageTraceId\":null,\"senderId\":null,\"applicationSessionId\":null},\"userId\":\"username\",\"uuid\":0}}"
   
],
   
"responseData": "{\"data\":{\"requestContext\":null,\"digitalIdEbo\":{\"id\":935,\"username\":\"bl...@some.com\",\"password\":\"5AED6242E91AEA045306CDA531121FF966DB321F\"}}}",
   
"eventLocation": "ADAPTOR",
   
"applicationSessionId": "dwifj334uhdgfff",
   
"applicationVersion": "NOT_SUPPLIED"
}


I would like to expand the requestData and responseData field as part of the document when I insert it into elasticsearch.

Is there a mapping for such type - i.e. expand the quoted JSON string and merge it into the JSON document?

The result document should look something like:

{
   
"methodName": "getDigitalId()",
   
"host": "localhost",
   
"threadName": "960894892@qtp-699536522-6(355)",
   
"requestData": [
     
{
         
"data": {
           
"requestContext": {
               
"messageTraceId": null,
               
"senderId": null,
               
"applicationSessionId": null
           
},
           
"userId": "username",
           
"uuid": 0
         
}
     
}
   
],
   
"responseData": {
     
"data": {
         
"requestContext": null,
         
"digitalIdEbo": {
           
"id": 935,
           
"username": "[hidden email]",
           
"password": "5AED6242E91AEA045306CDA531121FF966DB321F"
         
}
     
}
   
},
   
"eventLocation": "ADAPTOR",
   
"applicationSessionId": "dwifj334uhdgfff",
   
"applicationVersion": "NOT_SUPPLIED"
}

thanking you in advance.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/2693e81c-252e-42bb-81d3-6cad639e6918%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.