Hi guys,
I am trying to create an index with the following code:
XContentBuilder source = XContentFactory.jsonBuilder().startObject()//
.startObject("settings")
.field("number_of_shards", 1)
.endObject()// end settings
.startObject("mappings")
.startObject(INDEX_TYPE)//
.startObject("properties")//
.startObject("user")
.field("type", "string") // start user
.field("store", "yes")
.field("index", "analyzed")//
.endObject()// end user
.startObject("postDate")//
.field("type", "date")
.field("store", "yes")
.field("index", "analyzed")//
.endObject()// end post date
.startObject("message") //
.field("type", "string")
.field("store", "yes")
.field("index", "not_analyzed")
.endObject() // end user field
.endObject() // end properties
.endObject() // end index type
.endObject() // end mappings
.endObject(); // end the container object
IndexResponse response = this.client.prepareIndex(INDEX, INDEX_TYPE
).setSource(source)
.setType(INDEX_TYPE).execute()
.actionGet();
I want to have the "message" field not analyzed, because later I want to
use facets to obtain unique messages.
Unfortunately my code seems to add just a document in index with the
following structure:
{
"settings": {
"number_of_shards": 1
},
"mappings": {
"tweet": {
"properties": {
"user": {
"type": "string",
"store": "yes",
"index": "analyzed"
},
"postDate": {
"type": "date",
"store": "yes",
"index": "analyzed"
},
"message": {
"type": "string",
"store": "yes",
"index": "not_analyzed"
}
}
}
}
}
Please help me to spot the error, it seems that mapping are not created.
Thank you very much,
Doru
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/d6635c65-41e5-43e9-b477-908f320127c5%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.