rawField in XContentBuilder

I have a string which is data in JSON format, but not in fixed structure. I
want to index it as a part of my document.
So, I'd have such structure:
{
"data":{ HERE is the CONTENT from the STRING with DYNAMIC STRUCTURE},
"mySecondProp":"Some Value, etc.."
}
I'm building XContentBuilder for indexing such document. I suspect that I
could use:

rawField<http://www.thelastcitadel.com/lab/elasticsearch/javadoc/org/elasticsearch/common/xcontent/builder/XContentBuilder.html#rawField(java.lang.String,
byte[])>(java.lang.String fieldName, byte[] content)

First of all, I need a confirmation that I'm in the right direction, since
I couldn't find description of that method.
And another question, should this work Ok?

rawField<http://www.thelastcitadel.com/lab/elasticsearch/javadoc/org/elasticsearch/common/xcontent/builder/XContentBuilder.html#rawField(java.lang.String,
byte[])>("data", myJsonString.getBytes());

Thank you,
Eugene

--

I think you are on the right track. As long as your XContentBuilder is
building JSON and your string is has correct JSON format it should work.

On Saturday, January 5, 2013 1:56:37 AM UTC-5, Eugene Strokin wrote:

I have a string which is data in JSON format, but not in fixed structure.
I want to index it as a part of my document.
So, I'd have such structure:
{
"data":{ HERE is the CONTENT from the STRING with DYNAMIC STRUCTURE},
"mySecondProp":"Some Value, etc.."
}
I'm building XContentBuilder for indexing such document. I suspect that I
could use:

rawFieldhttp://www.thelastcitadel.com/lab/elasticsearch/javadoc/org/elasticsearch/common/xcontent/builder/XContentBuilder.html#rawField(java.lang.String,+byte[])(java.lang.String
fieldName, byte content)

First of all, I need a confirmation that I'm in the right direction, since
I couldn't find description of that method.
And another question, should this work Ok?

rawFieldhttp://www.thelastcitadel.com/lab/elasticsearch/javadoc/org/elasticsearch/common/xcontent/builder/XContentBuilder.html#rawField(java.lang.String,+byte[])("data",
myJsonString.getBytes());

Thank you,
Eugene

--