Elastic term frequency query


(Ivan Zinchenko) #1

Hi everyone,

anybody had to deal with the type of term frequency queries like: "match
documents that have W word in F field at least N times"?
seems like dismax is not the right medicine here, and there are no
dedicated term freq query as far as i know.

i actually managed to do that using span query, for example - match 'word'
in 'field' at least 3 times:
{
"span_near": {
"clauses": [
{
"span_term": {
"field": "word"
}
},
{
"span_term": {
"field": "word"
}
},
{
"span_term": {
"field": "word"
}
}
],
"slop": 2147483647,
"in_order": true
}
}

is this the only way of doing that, optimal way? or am i missing something?

Thx.


(system) #2