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
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
On Wednesday, February 5, 2014 1:27:41 AM UTC+11, Doru Sular wrote:
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
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
Create Index refhttp://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-create-index.html#mappingssays mappings can be included in index settings JSON. Are you saying that's
not supported by the Java client? (Fwiw, I am seeing the same - just wanted
to confirm):
the following settings successfully create index with predefined mappings
when using curl put /idx -d @settings.json but not when fed to java client
like so:
On Wednesday, February 5, 2014 1:27:41 AM UTC+11, Doru Sular wrote:
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
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
On Thursday, March 13, 2014 9:58:56 AM UTC-7, Nikita Tovstoles wrote:
Hi, Kevin:
Create Index refhttp://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-create-index.html#mappingssays mappings can be included in index settings JSON. Are you saying that's
not supported by the Java client? (Fwiw, I am seeing the same - just wanted
to confirm):
the following settings successfully create index with predefined mappings
when using curl put /idx -d @settings.json but not when fed to java client
like so:
On Wednesday, February 5, 2014 1:27:41 AM UTC+11, Doru Sular wrote:
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
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
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.