Is this code correct for storing fields?


(Saurabh) #1

this a sample code, will it store the "message" field?

    IndexRequestBuilder req = client.prepareIndex("twitter", "tweet")
            .setSource(jsonBuilder()
                    .startObject()
                        .field("user", "kimchy")
                        .field("postDate", "12 June")
                        .field("message", "trying out Elastic Search")
                        .field("properties").startObject()
                        .field("message").startObject()
                        .field("store","yes")
                        .field("index","analyzed")
                        .endObject()
                        .endObject()
                    .endObject()
                  );
    bulkRequest.add(req);

Urgent Help needed.


(Shay Banon) #2

The whole document is stored by default (under a special field called
_source), so yes, the message will be part of it.

On Wed, Jun 13, 2012 at 1:40 PM, Saurabh saurabh.k1510@gmail.com wrote:

this a sample code, will it store the "message" field?

    IndexRequestBuilder req = client.prepareIndex("twitter", "tweet")
            .setSource(jsonBuilder()
                    .startObject()
                        .field("user", "kimchy")
                        .field("postDate", "12 June")
                        .field("message", "trying out Elastic Search")
                        .field("properties").startObject()
                        .field("message").startObject()
                        .field("store","yes")
                        .field("index","analyzed")
                        .endObject()
                        .endObject()
                    .endObject()
                  );
    bulkRequest.add(req);

Urgent Help needed.


(Saurabh) #3

Thanks, but is there any way to check whether a field is stored or not, i
mean not the _source field, the fields which i store explicitly.

On Fri, Jun 15, 2012 at 3:02 AM, Shay Banon kimchy@gmail.com wrote:

The whole document is stored by default (under a special field called
_source), so yes, the message will be part of it.

On Wed, Jun 13, 2012 at 1:40 PM, Saurabh saurabh.k1510@gmail.com wrote:

this a sample code, will it store the "message" field?

    IndexRequestBuilder req = client.prepareIndex("twitter", "tweet")
            .setSource(jsonBuilder()
                    .startObject()
                        .field("user", "kimchy")
                        .field("postDate", "12 June")
                        .field("message", "trying out Elastic Search")
                        .field("properties").startObject()
                        .field("message").startObject()
                        .field("store","yes")
                        .field("index","analyzed")
                        .endObject()
                        .endObject()
                    .endObject()
                  );
    bulkRequest.add(req);

Urgent Help needed.

--
Saurabh Kumar
M.Sc (Mathematics) B.E (Computer Science)
Birla Institute of Technology and Science-Pilani


(system) #4