The error originates from FieldValueFactorFunctionParser.java 
<https://github.com/elastic/elasticsearch/blob/528f6481eaadd2a0585dc6731a94d7a024b8ce29/src/main/java/org/elasticsearch/index/query/functionscore/fieldvaluefactor/FieldValueFactorFunctionParser.java>
 (line 
89), in FieldValueFactorFunctionParser. 
Is there really a need to check for the existence of all fields during 
parsing? 
With other function, this is not done, so no problem if a field does not 
exist, yet.

Best regards,
Tobias

On Wednesday, April 29, 2015 at 2:13:19 PM UTC+2, Tobias Schubotz wrote:
>
> Hi,
>
> My ES function score query contains several different functions based on a 
> set of different fields. I'm having problems with field_value_factor on not 
> existing fields.
> I'm not sure if that's existing behavior or a bug in ES.
>
> Here a minimal example on how to reproduce the problem:
>
> Example document:
> curl -XPOST "http://localhost:9200/blog/page/1?pretty"; -d '
> {
>   "author": "tobias",
>   "content": "Great",
>   "views": 1
> }'
>
> A search request, that boosts based on the function score looks like that:
> curl -XPOST "http://localhost:9200/blog/_search"; -d '
> {
>   "query": {
>     "function_score": {
>       "functions": [
>         {
>           "field_value_factor": {
>             "field": "views",
>             "modifier": "log2p"
>           }
>         }
>       ]
>     }
>   }
> }'
>
> Everything is fine until this point.
> When I change the "field" param to "likes", the requests fails:
> curl -XPOST "http://localhost:9200/blog/_search"; -d '
> {
>   "query": {
>     "function_score": {
>       "functions": [
>         {
>           "field_value_factor": {
>             "field": "likes",
>             "modifier": "log2p"
>           }
>         }
>       ]
>     }
>   }
> }'
> -> ElasticsearchException[Unable to find a field mapper for field [likes]
>
>
> "likes" doesn't exist yet in the "page" document type, but it might exist 
> in the future. Or there could be another type "page2", where the "likes" 
> field exist, and I need to query both "page" and "page2" in 1 request.
>
> What I tried, is to put an exist filter beforehand, however, the error 
> remains the same.
> curl -XPOST "http://localhost:9200/blog/_search"; -d '
> {
>     "query": {
>         "function_score": {
>             "functions": [
>                 {
>                     "filter": {
>                         "exists": {
>                             "field": "likes"
>                         }
>                     },
>                     "field_value_factor": {
>                         "field": "likes"
>                     }
>                 }
>             ]
>         }
>     }
> }'
> -> ElasticsearchException[Unable to find a field mapper for field [likes]
>
> Is this a bug or expected bahavior?
> I would expect ES to just skip the function, in case the "exists" filter 
> evaluates to False or the field doesn't exist. 
>
> With other function types, there is no problem. E.g. the following works 
> without an error:
> curl -XPOST "http://localhost:9200/blog/_search"; -d '
> {
>   "query": {
>     "function_score": {
>       "functions": [
>         {
>             "filter": {
>                 "range": {"likes": {"from": 1}}
>             }, 
>             "weight": 1.5
>         }
>       ]
>     }
>   }
> }'
>
> Any ideas?
>
> Let me know, if you need further information.
>
> Best regards,
> Tobias
>
>
>
>
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/36dfe2bf-b6c1-4d85-8e53-61526453bdc2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to