Approximate Matching with multiple phrases

Hello everyone,

Well, I was wondering if Elasticsearch does have the "Slop" option for phrases too?
I mean, I know I can search for a phrase (say "keyword1 keyword2") and set a maximum distance between those two keywords like that :

GET INDEX/TYPE/_search
{
"query": {
"query_string": {
"fields": ["field1", "field2"],
"query": " "keyword1 keyword2"~3 "
}
}
}

.. but can I do the same with two phrases? ("Phrase1" "Phrase2")?

Another question, I'm using query string clauses .. is there a way to set a slop for the ANDed keywords?
I mean something like that:

GET INDEX/TYPE/_search
{
"query": {
"query_string": {
"fields": ["field1", "field2"],
"query": "(keyword1 AND keyword2)~3"
}
}
}

or more, can I do something like that?

GET INDEX/TYPE/_search
{
"query": {
"query_string": {
"fields": ["field1", "field2"],
"query": "( (set of ORed keywords) AND (set of ORed keywords) )~3"
}
}
}

I'm using the latest version of ES.

Thanks a lot.

Take a look at span queries - they provide the syntax for more advanced forms of position checking

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.