Do I have to explicitly exclude the _all field in queries?

Hi all,

I clearly haven't completely grokked something in how QueryString queries
are interpreted. Consider the following query:

{
"query": {
"query_string": {
"analyze_wildcard": true,
"query": "Node.author:Brian Levine"
}
},
"fields": ["Node.author"],
"explain":true
}

Note: The Node.author field is not_analyzed.

The results from this query include documents for which the Node.author
field contains neither "Brian" nor "Levine". In examining the the
explanation, I found that the documents were included because another field
in the document contained "Levine." A snippet from the explanation shows
that the _all field was considered:

{
"value": 0.08775233,
"description": "weight(_all:levine in 464) [PerFieldSimilarity], result
of:",
...

Do I need to explicitly exclude the _all field in the query?

Separate question: Because the Node.author field is not_analyzed, I had
thought that the value "Brian Levine" would also not be analyzed and
therefore only documents whose Node.author field contained "Brian Levine"
exactly would be matched, yet the explanation shows that the "brian" and
"levine" tokens were considered. I also noticed that if I change the query
to:

"query: "Node.author:(Brian Levine)"

then result set changes. Only the documents whose Node.author field
contains either "brian" OR "levine" are included (which is what I would
have expected). According to the explanation, the _all field is not
considered in this query.

So I'm confused. Clearly, I don't understand how my original query is
interpreted.

Hopefully, someone can enlighten me.

Thanks.

-brian

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/120103bc-a60d-418a-b092-09f71732b682%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

OK, I think I figured this out. It's the space between "Brian" and
"Levine". The query:

"query": "Node.author:Brian Levine"

is actually interpreted as Node.author:Brian OR Levine in which case
"Levine" is searched for in the _all field. Seems so obvious now! :wink:

-b

On Tuesday, March 24, 2015 at 1:50:42 PM UTC-4, Brian Levine wrote:

Hi all,

I clearly haven't completely grokked something in how QueryString queries
are interpreted. Consider the following query:

{
"query": {
"query_string": {
"analyze_wildcard": true,
"query": "Node.author:Brian Levine"
}
},
"fields": ["Node.author"],
"explain":true
}

Note: The Node.author field is not_analyzed.

The results from this query include documents for which the Node.author
field contains neither "Brian" nor "Levine". In examining the the
explanation, I found that the documents were included because another field
in the document contained "Levine." A snippet from the explanation shows
that the _all field was considered:

{
"value": 0.08775233,
"description": "weight(_all:levine in 464) [PerFieldSimilarity],
result of:",
...

Do I need to explicitly exclude the _all field in the query?

Separate question: Because the Node.author field is not_analyzed, I had
thought that the value "Brian Levine" would also not be analyzed and
therefore only documents whose Node.author field contained "Brian Levine"
exactly would be matched, yet the explanation shows that the "brian" and
"levine" tokens were considered. I also noticed that if I change the query
to:

"query: "Node.author:(Brian Levine)"

then result set changes. Only the documents whose Node.author field
contains either "brian" OR "levine" are included (which is what I would
have expected). According to the explanation, the _all field is not
considered in this query.

So I'm confused. Clearly, I don't understand how my original query is
interpreted.

Hopefully, someone can enlighten me.

Thanks.

-brian

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/63c5fff3-cfd5-4003-89ad-015d8fdb4879%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.