Hi there,
I have an issue related to query_string
using the "+" operator. Suppose that my index contains the documents below:
doc_1
{
field1: "foo bar",
field2: "zoo"
}
doc_2
{
field1: "foo",
field2: "bar"
}
Now, consider the following query_string:
{
query_string:{
query: foo bar
fields: [field1^5, field2],
default_operator: 'AND'
}
}
Executing it, only the first document is returned, as foo and bar only occurs in one field (I'm not using quotation marks!)
If I change my query term to foo + bar
{
query_string:{
query: foo + bar
fields: [field1^5, field2],
default_operator: 'AND'
}
}
both documents are returned, as the second document contains foo in one field and bar in another field.
My point is: Why should I force the "+" operator do have the second result, as I'm not using quotations in the first query? It seems that the "+" operator is much more than just force the terms to be presented in the document, it, somehow, tells the query_string to find the occurrence of them across the fields (I don't intend to use multi_match cross_field
DSL!)
I'm asking that, because it's something that is not clear in the reference:
https://www.elastic.co/guide/en/elasticsearch/reference/5.5/query-dsl-query-string-query.html
which says that, the "+" operator is similar to the default_operator = 'AND'
.
Am I wrong?? What have I missed in my first query_string
to have the terms searched across the fields and not the obligation to have all of them presented in one field??
Thanks,
Guilherme