Query is below
{
"query": {
"bool": {
"must": {
"query_string": {
"query": "messi NOT barca AND psg",
"fields": ["name^128"]
}
}
}
}
}
What is the difference in "query": "messi AND barca NOT psg"
What is order of precedence in AND, OR, NOT in DSL
CodePudding user response:
TLDR;
The familiar boolean operators AND, OR and NOT (also written &&, || and !) are also supported but beware that they do not honor the usual precedence rules, so parentheses should be used whenever multiple operators are used together.
Depending on what you want to need to set your parenthesis right.
To understand
messi NOT barca AND psg
-> will match messi psg
messi AND barca NOT psg
-> will match messi barca
messi NOT (barca AND psg)
-> will match messi barca
or messi psg
but not messi barca psg