Trouble querying multiple keys

Hey

Trying to figure out how to use the default_operator using a URI request.
I'm searching for words / phrases in two different keys:

  • Search for firstName contains "John"
    AND
  • Search for note contains "Some testnotes"

See query below:

/contacts/_search?q=+firstName:John+note:some%20testnotes&default_operator=AND

However, elasticsearch returns records where "some" and "testnotes" are
found separately in the "note" key.
How can I solve this?

TIA

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

First of all, because query string is URL encoded both "+" and %20 on URL
are getting converted into spaces. But this is not what is causing the
problem. When search string is getting parsed, elasticsearch recognizes
space between "some" and "testnotes" as a separator between two different
field clauses. Because testnotes doesn't have a field associated with it,
the default _all field is getting used. So, your search is getting
translated into

firstName:John note:some _all:testnotes

It can be fixed by surrounding note some and testnotes with parenthesis (if
you want to find both words anywhere in the field note) or quites (if you
want to find the word "some" and "testnotes" next to each other):

firstName:John%20note:(some%20testnotes)

On Friday, April 19, 2013 2:01:11 PM UTC+2, woodwood wrote:

Hey

Trying to figure out how to use the default_operator using a URI request.
I'm searching for words / phrases in two different keys:

  • Search for firstName contains "John"
    AND
  • Search for note contains "Some testnotes"

See query below:

/contacts/_search?q=+firstName:John+note:some%20testnotes&default_operator=AND

However, elasticsearch returns records where "some" and "testnotes" are
found separately in the "note" key.
How can I solve this?

TIA

--
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.
For more options, visit https://groups.google.com/groups/opt_out.