Hello everybody,
I use the following two mappings in a parent child deployment:
curl -X PUT "localhost:9200/parchildev/attachment/_mapping" -d '{
"attachment" : {
"properties" : {
"file" : {
"type" : "attachment",
"fields" : {
"title" : { "store" : "yes" },
"file" : { "term_vector":"with_positions_offsets", "store":"yes" }
}
}
}
}
}'
curl -X PUT 'localhost:9200/parchildev/comment/_mapping' -d '{
"comment" : {
"_parent" : {
"type" : "attachment"
},
"properties" : {
"user" : {"type" : "string"},
"message" : {"type" : "string", "null_value" : "na"},
"car": {"type" : "string"}
}
}
}'
Then I index a pdf into attachment which works fine
Now I put the following to the child mapping:
curl -XPUT 'localhost:9200/parchildev/comment/1?parent='
-d '{
"user":"esuser",
"message":"amplifier",
"car":"audi a4"
}'
If I now query, the inner query returns an error message
curl "${host}/_search?pretty=true" -d '{
"fields" : ["title"],
"query": {
"bool": {
"must": [
{
"has_child": {
"type": "comment",
"query": {
"query_string" : {
"query" : "amplifier"
}
}
}
}
]
}
},
"highlight" : {
"fields" : {
"file" : {}
}
}
}'
{
"took" : 5,
"timed_out" : false,
"_shards" : {
"total" : 2,
"successful" : 1,
"failed" : 1,
"failures" : [ {
"index" : "test",
"shard" : 0,
"status" : 400,
"reason" : "SearchParseException[[test][0]: from[-1],size[-1]: Parse
Failure [Failed to parse source [{\n"fields" : ["title"],\n "query":
{\n "bool": {\n "must": [\n {\n "has_child":
{\n "type": "comment",\n "query":
{\n"query_string" : {\n"query" : "amplifier"\n}\n
}\n }\n }\n ]\n }\n },\n\n"highlight" :
{\n"fields" : {\n"file" : {}\n}\n}\n}]]]; nested:
QueryParsingException[[test] [has_child] Type [comment] does not have
parent mapping]; "
} ]
},
"hits" : {
"total" : 0,
"max_score" : null,
"hits" : [ ]
}
How to define the child mapping? I didn't find any working minimal
examples...
I used the following two sites
http://www.elasticsearch.org/guide/reference/mapping/parent-field.html and
http://www.elasticsearch.org/guide/reference/mapping/