I am working on a search query against an Elasticsearch search index. Sometimes, I want to require that a term be present. To address this scenario, I've been reading about the "+" boolean operator . However, I'm slightly confused by it.
I do not understand where it fits against the AND (&&) operator and using the phrase operator ("). For example, lets say I had a search index of animals. Imagine I wanted to find foxes. How is
brown +fox
different from brown && fox
different from "brown" && "fox"
. In my understanding, these are very similar. I understand how the last two differ. However, for the life of me, I do not understand why I would ever use the "+" operator.
Any help is appreciated.
for the life of me, I do not understand why I would ever use the "+" operator.
+
: this term must be present
-
: this term must not be present
All other terms are optional. For example, this query:
quick brown +fox -news
states that:
fox
must be present news
must not be present quick
and brown
are optional — their presence increases the relevance Phrase Query :
Phrase
, surrounded by double quotes —
"quick brown"
— searches for all the words in the phrase, in the same order
AND
and &&
are both the same operators ie both must be present.
I hope it clarifies.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.