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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/f382e8d1-09f9-410f-ad6b-1a9d7fd8a6b8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.