My understanding of Constant Score Query in elasticsearch is that boost
factor would be assigned as score for every matching query. The
documentationhttp://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-constant-score-query.html
says:
A query that wraps a filter or another query and simply returns a constant
score equal to the query boost for every document in the filter.
However when I send this query:
"query": {
"constant_score": {
"filter": {
"term": {
"source": "BBC"
}
},
"boost": 3
}
},
"fields": ["title", "source"]
all the matching documents are given a score of 1?! I cannot figure out
what I am doing wrong, and had also tried with query instead of filter in
constant_score.
I've also tried using Function Score Query
"query": {
"function_score": {
"query": {
"term": {
"source": "gdrive"
}
},
"script_score": {
"script": "3"
}
}
},
"fields": [
"title",
"source"
]
But the score is not set to 3, but to what seems to be the Lucene score for the document.
Any idea of what I am doing wrong?!
Thanks,
Ilija
--
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/d1189650-a38c-4de3-8c06-b91d7703ee39%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
For the first one, you are probably experiencing score normalization
happening. If you add explain: true to the query, it will tell you how it
is being normalized.
For the second one, if you want the function_score to totally override the
Lucene score, you can "replace" the Lucene score with whatever comes out of
the function_score:
{
"query": {
"function_score": {
"query": {...}
},
"script_score": {
"script": "3"
},
"boost_mode": "replace"
}
}
}
--
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/fc443609-1208-4412-bfdd-40a788f4a58a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Ahh, thanks. Thought as much about the normalization. Can it be turned off
anywhere except in the mapping?
Function score works with boost_mode=replace!
On Friday, May 9, 2014 3:04:57 PM UTC+2, Binh Ly wrote:
For the first one, you are probably experiencing score normalization
happening. If you add explain: true to the query, it will tell you how it
is being normalized.
For the second one, if you want the function_score to totally override the
Lucene score, you can "replace" the Lucene score with whatever comes out of
the function_score:
{
"query": {
"function_score": {
"query": {...}
},
"script_score": {
"script": "3"
},
"boost_mode": "replace"
}
}
}
--
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/6c998b20-5db2-49f7-acfa-eb8569c28953%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.