Question 1
Is there a preferred way to write a query that consists solely of filters -
that is, return documents iff they pass a set of filters?
From thishttp://elasticsearch-users.115913.n3.nabble.com/Filters-vs-Queries-td3219558.htmlthread, I've gathered that there are two options:
-
Constant Score:
{ query: {
constant_score: {
filter: {...},
filter: {...},
filter: {...}
}
}} -
Filtered:
{ query: {
filtered: {
filter: {...},
filter: {...},
filter: {...}
}
}}
Am I right that these will produce identical results? Is there a reason to
prefer one over the other?
Question 2
I'd like to write a query that first uses filters to limit to a subset of
documents (as in question 1), then uses function scoring with filters to
score each of the the documents in the subset.
A year ago, I used custom_filters_score, like so:
{
"query":{
"custom_filters_score":{
"query":{
"filtered":{
"query":{
"match_all":{
}
},
"filter":{
"and":[
-
<limiting filters>* ] } } }, "filters":[
-
}<scoring filters>* ], "params":{ }, "score_mode":"total" }
}
Now, with function score query, I'm thinking:
{
"query":{
"function_score":{
"functions":[
* *
],
"query":{
"filtered":{
"query":{
"match_all":{
}
},
"filter":{
"and":[
* <limiting filters>*
]
}
}
},
"score_mode":"first"
}
}
}
Is this the best way to achieve what I want?
--
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/b8c0ac6d-b496-4b6e-b5f5-4b510b4ac634%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.