Multiword exact search

Hello,

I would kindly ask how to make multi words search with multi keywords. I would like to achive following for SATB2 syndrome would like that I found exact following words:
Prader-Willi syndrome (all varation of low and capital latters, but remain word order)
Prader Willi syndrome (the same as above)
#PraderWilliSyndrome (the same as above)
#PraderWilli (the same as above)

The problem is that somtimes finds autor as Prader or Willi which is wrong I would need exact words order happen in text.

My python code is as is following:


    query = {
        "query": {
            "query_string": {
                "query": (Prader-Willi syndrome) OR Prader Willi syndrome) OR (#PraderWilliSyndrome) OR (#PraderWilli),
                "default_operator": "AND",
                "default_field": "text"
            }
        },
        "_source": ["id"]
    }
    res = es.search(index=index, body=query, scroll='60m', size=10000, request_timeout=30)

I do query_string try to use AND operator, that every word in brackets will be searched as exact.
How is possible that it found Prader or Willi separatly without other words ?

Hello Matej, welcome to the community!

Have you tried each of these phrases surrounded by double quotes?

Something like:


"query": "\"Prader-Willi syndrome\" OR \"Prader Willi syndrome\" OR \"#PraderWilliSyndrome\" OR \"#PraderWilli\"",

You can read more about the syntax here.

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