# Version 1.2.1 has\_child query with function\_score can not access child's numeric field value

**URL:** https://discuss.elastic.co/t/version-1-2-1-has-child-query-with-function-score-can-not-access-childs-numeric-field-value/18148
**Category:** Elasticsearch
**Created:** [June 17, 2014, 8:18am UTC](https://discuss.elastic.co/t/version-1-2-1-has-child-query-with-function-score-can-not-access-childs-numeric-field-value/18148 "2014-06-17T08:18:42Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![fiefdx\_yang](https://avatars.discourse-cdn.com/v4/letter/f/bc8723/32.png) [@fiefdx\_yang](https://discuss.elastic.co/u/fiefdx_yang)
#### Post date: [June 17, 2014, 8:18am UTC](https://discuss.elastic.co/t/version-1-2-1-has-child-query-with-function-score-can-not-access-childs-numeric-field-value/18148/1 "2014-06-17T08:18:42Z")

</div>

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

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [July 6, 2017, 1:21am UTC](https://discuss.elastic.co/t/version-1-2-1-has-child-query-with-function-score-can-not-access-childs-numeric-field-value/18148/2 "2017-07-06T01:21:54Z")

</div>


