Can you run the validate query output. That will be helpful. amish On Thursday, November 6, 2014 4:47:12 PM UTC-8, Dave Reed wrote: > > I have a document with a field "message", that contains the following text > (truncated): > > Welcome to test.com! > > The assertion field is mapped to have an analyzer that breaks that string > into the following tokens: > > welcome > to > test > com > > But, when I search with a query like this: > > { > "query": { > > "query_string": { > "query": "id:3955974 AND message:welcome-doesnotmatchanything" > } > } > } > > > > To my surprise, it finds the document (3955974 is the document id). The > dash and everything after it seems to be ignored, because it does not > matter what I put there, it will still match the document. > > I've tried escaping it: > > { > "query": { > "query_string": { > "query": "id:3955974 AND message:welcome\\-doesnotmatchanything" > } > } > } > (note the double escape since it has to be escaped for the JSON too) > > But that makes no difference. I still get 1 matching document. If I put it > in quotes it works: > > { > "query": { > "query_string": { > "query": "id:3955974 AND message:\"welcome-doesnotmatchanything\"" > } > } > } > > It works, meaning it matches 0 documents, since that document does not > contain the "doesnotmatchanything" token. That's great, but I don't > understand why the unquoted version does not work. This query is being > generated so I can't easily just decide to start quoting it, and I can't > always do that anyway since the user is sometimes going to use wildcards, > which can't be quoted if I want them to function. I was under the > assumption that an EscapedUnquotedString is the same as a quoted unespaced > string (in other words, foo:a\b\c === foo:"abc", assuming all special > characters are escaped in the unquoted version). > > I'm only on ES 1.01, but I don't see anything new or changes that would > have impacted this behavior in later versions. > > Any insights would be helpful! :) > > > > >
-- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/7790c6fc-5578-4434-9bd2-fd846e59a997%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.