Veda
2014-01-01 17:49:35 UTC
Hi,
An example document in the index is
{
"title": "Red Gucci Dress",
"merchant": "zara",
"price": 1972.34,
"colours": [{"name": "red", "emd": 1.98, "percentage": 45}, {"name":
"blue", "emd": 1.99, "percentage": 40}]
}
and i have defined a mapping to let ES know colours is a nested object by
posting the following json
{
"nested_product" : {
"properties" : {
"colours" : {
"type" : "nested"
}
}
}
}
I'm facing an issue when i want to use custom_filter_score and in the
scoring script I want to use the matched colour's properties to generate the
score. Below is the query
{
"query":{
"custom_filters_score" : {
"query": {"match_phrase": {"_all" : "gucci dress"}},
"filters" : [{
"filter" : { "nested" : { "path" : "colours", "filter" :
{"term" : {"colours.name" : "blue"}}}},
"script" : "foreach(colour : doc['colours'].values){ if
(colour.name == 'blue') {return ((0.1 * colour.percentage * colour.emd));}}"
}
],
"score_mode" : "total"
}
}
}
which throws an error
Query Failed [Failed to execute main query]]; nested:
CompileException[[Error: No field found for [colours] in mapping with types
[nested_product]]\n[Near : {... foreach(colour : doc['colours' ....}]\n
^\n[Line: 1, Column: 1]]; nested: ElasticSearchIllegalArgumentException[No
field found for [colours] in mapping with types [nested_product]]; "
Any help on it would be appreciated
Thanks in Advance,
Veda
--
View this message in context: http://elasticsearch-users.115913.n3.nabble.com/Using-a-nested-object-property-within-custom-filters-score-script-tp4046901.html
Sent from the ElasticSearch Users mailing list archive at Nabble.com.
An example document in the index is
{
"title": "Red Gucci Dress",
"merchant": "zara",
"price": 1972.34,
"colours": [{"name": "red", "emd": 1.98, "percentage": 45}, {"name":
"blue", "emd": 1.99, "percentage": 40}]
}
and i have defined a mapping to let ES know colours is a nested object by
posting the following json
{
"nested_product" : {
"properties" : {
"colours" : {
"type" : "nested"
}
}
}
}
I'm facing an issue when i want to use custom_filter_score and in the
scoring script I want to use the matched colour's properties to generate the
score. Below is the query
{
"query":{
"custom_filters_score" : {
"query": {"match_phrase": {"_all" : "gucci dress"}},
"filters" : [{
"filter" : { "nested" : { "path" : "colours", "filter" :
{"term" : {"colours.name" : "blue"}}}},
"script" : "foreach(colour : doc['colours'].values){ if
(colour.name == 'blue') {return ((0.1 * colour.percentage * colour.emd));}}"
}
],
"score_mode" : "total"
}
}
}
which throws an error
Query Failed [Failed to execute main query]]; nested:
CompileException[[Error: No field found for [colours] in mapping with types
[nested_product]]\n[Near : {... foreach(colour : doc['colours' ....}]\n
^\n[Line: 1, Column: 1]]; nested: ElasticSearchIllegalArgumentException[No
field found for [colours] in mapping with types [nested_product]]; "
Any help on it would be appreciated
Thanks in Advance,
Veda
--
View this message in context: http://elasticsearch-users.115913.n3.nabble.com/Using-a-nested-object-property-within-custom-filters-score-script-tp4046901.html
Sent from the ElasticSearch Users mailing list archive at Nabble.com.
--
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-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/1388598575084-4046901.post%40n3.nabble.com.
For more options, visit https://groups.google.com/groups/opt_out.
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-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/1388598575084-4046901.post%40n3.nabble.com.
For more options, visit https://groups.google.com/groups/opt_out.