I'm guessing you're using the default standard analyzer, which strips the hyphen and understands your string as two separate tokens. You can test this using the analyze api:
GET /_analyze
{
"analyzer": "standard",
"text": "test-qzw"
}
If you want to do a text search interpreting hyphens in a different way, you'll need to use a different analyzer. Note that since these have been indexed with the standard analyzer already using a whitespace analyzer or something at search time won't work the way you want.
Thanks for reply, so the tokenizer will still apply to my search content in math_phrase,but what I need is to make a search to hit "test-qzw" when I search for "test", so I still need the tokenizer to use hyphen to tokenize my string, but I alse need a way to hit only stings containing "test-qzw" but not "test qzw"
(thanks to my god damn app scenario). Is there any possible to make this realized by Elasticsearch?
I think you could do this with a custom tokenizer and analyzer with some fiddling. But if you don't want to go down that route the only other option would be to use keyword fields which it doesn't sound like you want.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.