Version 1.2.1 has_child query with function_score can not access child's numeric field value


(fiefdx yang) #1

curl -XPOST 'localhost:9200/products/' -d '{
"index" : {
"number_of_shards" : 4,
"number_of_replicas" : 1
}
}'
echo ""

curl -XPOST localhost:9200/products/product/_mapping -d '{
"product":{
"properties" : {
"property1" : {"type" : "string"}
}
}
}'
echo ""

curl -XPOST localhost:9200/products/offer/_mapping -d '{
"offer":{
"_parent": {"type": "product"},
"properties" : {
"color" : {"type" : "string"},
"size" : {"type" : "integer"},
"price" : {"type" : "float"}
}
}
}'
echo ""

curl -XPUT localhost:9200/products/product/1 -d'{
"property1": "value1"
}'
echo ""

curl -XPUT localhost:9200/products/product/2 -d'{
"property1": "value2"
}'
echo ""

curl -XPOST localhost:9200/products/offer/1?parent=1 -d '{
"color": "blue",
"size": 1,
"price": 99.4
}'
echo ""

curl -XPOST localhost:9200/products/offer/2?parent=1 -d '{
"color": "red",
"size": 2,
"price": 100.5
}'
echo ""

curl -XPOST localhost:9200/products/offer/3?parent=2 -d '{
"color": "blue",
"size": 3,
"price": 100.7
}'
echo ""

search script as:
curl -s -XPOST 'localhost:9200/products/product,offer/_search?pretty=true'
-d '{
"query" : {
"has_child" : {
"type" : "offer",
"score_mode" : "max",
"query" : {
"function_score" : {
"boost_mode" : "replace",
"query" : {
"bool" : {
"must" : [
{ "term" : { "color" : "blue" } }
]
}
},
"script_score" : {
"script" : "doc['offer.price'].value"
}
}
}
}
}
}'
echo ""

get exception:
nested: PropertyAccessException[[Error: could not access: offer; in class:
org.elasticsearch.search.lookup.DocLookup]\n[Near : {...
doc[offer.price].value ....}

Can function_score get child's numeric field as parent's score like version
0.90.x custom_score did?

--
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/0fcc7198-a84b-4ac4-804f-e7c5d0aaa501%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(system) #2