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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/1dbfa1d5-7301-460b-ae9c-3665cfa79c96%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to