Hi,
I am trying to use dynamic mapping where I want to use dynamic templates.
But it looks that if I have dynamic field name and value name , ES doesn't
create the mapping for this. It works when I have field as String, Number.
A problem is coming when I have field like json object (example: field
details)
{
"id": "abcd",
"details: {
"description": "text",
"number": 123
}
}
What I'm doing is:
/Step1
//I'm creating the index with the
settings:
//*********************
$ curl -XPOST "http://localhost:9200/nicka/" -d'
{
"settings":{
"number_of_shards":3,
"number_of_replicas":1
,"more":{},
"index" : {
"analysis" : {
"analyzer" : {
"autocomplete" : {
"tokenizer" : "whitespace",
"filter" : ["lowercase", "engram"]
}
},
"filter" : {
"engram" : {
"type" : "edgeNGram",
"min_gram" : 3,
"max_gram" : 10
}
}
}
}
}
}'
//Step2
//Define mapping:
//*********************************************************
$ curl -XPOST "http://localhost:9200/nicka/items/_mapping" -d'
{
"items" : {
"dynamic_templates" : [
{
"template_level_0" :{
"match" : "id*",
"match_mapping_type" : "string",
"mapping" : {
"type" : "string",
"index" : "not_analyzed"
}
}
},
{
"template_level_1" : {
"match" : "*",
"mapping" : {
"type" : "multi_field",
"fields" : {
"{name}" : {
"type" : "{dynamic_type}",
"index" : "analyzed",
"store": "yes",
"index_analyzer" : "autocomplete",
"search_analyzer" : "standard"
},
"original":{"type" : "string", "index":"not_analyzed"}
}
}
}
}
]
}
}'
/********Step3
//***************Create document:
//**************************************************************************
$ curl -XPUT "http://localhost:9200/nicka/items/1" -d'
{
"id" : "123-324-abcde",
"number" : 1 234567,
"details" : {
"description" : "some example text for document",
"name" : "document 1",
"number" : 1234567,
"driver" : "John Smith"
},
"tags" : ["document", "driver", "car"]
}'
{"ok":true,"_index":"nicka","_type":"items","_id":"1","_version":1}
- PROBLEM: When I am checking the mapping I have result this:
$ curl -XGET "http://localhost:9200/nicka/items/_mapping?pretty"
{
"items" : {
"dynamic_templates" : [ {
"template_level_0" : {
"mapping" : {
"type" : "string",
"index" : "not_analyzed"
},
"match" : "id*",
"match_mapping_type" : "string"
}
}, {
"template_level_1" : {
"mapping" : {
"type" : "multi_field",
"fields" : {
"{name}" : {
"type" : "{dynamic_type}",
"index" : "analyzed",
"store" : "yes",
"index_analyzer" : "autocomplete",
"search_analyzer" : "standard"
},
"original" : {
"type" : "string",
"index" : "not_analyzed"
}
}
},
"match" : "*"
}
} ],
"properties" : { }
}
}
As you see the properties is empty so it is not correct. When I'm create
simple document key-value I am able to see all mapping for these
relationships in this place: "properties".
/********Step4
//***************Search for test:
//**************************************************************************
When I'm trying to finde documet using filed: details.name I got correct
result:
$ curl -XGET "http://localhost:9200/nicka/items/_search?pretty" -d '
{
"query" : {
"term" : { "details.name" : "document" }
}
}'
{
"took" : 1,
"timed_out" : false,
"_shards" : {
"total" : 3,
"successful" : 3,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 0.30685282,
"hits" : [ {
"_index" : "nicka",
"_type" : "items",
"_id" : "1",
"_score" : 0.30685282, "_source" :
{
"id" : "123-324-abcde",
"details" : {
"description" : "some example text for document",
"name" : "document",
"number" : 1234567,
"driver" : "Nicka"
},
"tags" : ["document", "driver", "car"]
}
} ]
}
}
Could you check this and tell me why I have this error?
If I wrote something what is not clear, please let me know. I will try to
explain more.
Thanks a lot!
Nicka
--
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 elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/652c9f1d-80e6-437c-8720-68759e9282ca%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.