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 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]]; "
Colud you try to use _source.colours instead of doc[‘colours’].values?
Maybe, the field in doc means lucene’s field name.
I think that elasticsearch is indexed the nested field as “colours.name”, not object.
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 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]]; "
So, one possible way I found was to access via _source. My data structure was nested array of objects with name and value properties:
"aggs": {
"test": {
"sum": {
"script": "if(_source.containsKey("field_name")){for(e : _source["field_name"]){ ... }};..."
One caveat is that it is very slow compared to accessing via doc...
In my project, it was not a show stopper, but let me know if someone figures out a better way to handle this situation.
Thanks!
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.