Hi Alexey,
Your message field is analyzed by default using the Standard Analyzer:
This means your "test message" will become ["test", "message"].
On the other hand, the prefix query isn't analyzed. Which means "test" will
match but "test " won't, because you have no term that begins with that
string.
One solution for this is to index your message field as not_analyzed. This
will only generate the term "test message" which will match both "test" and
"test " prefixes. However, if you search for the "test" term, it won't
match because you have no such term.
You can have the best of both worlds by indexing the same text multiple
times with multiple settings:
Best regards,
Radu
Performance Monitoring * Log Analytics * Search Analytics
Solr & Elasticsearch Support * http://sematext.com/
On Thu, Apr 24, 2014 at 9:42 AM, Alexey Kotlyarov koterpillar@gmail.comwrote:
Given a simple index:
curl -XPUT http://localhost:9200/twitter/tweet/1 -d '{"message":
"test message"}'
A query for "test" returns the tweet:
curl -XPOST 'http://localhost:9200/twitter/tweet/_search?pretty' -d
'{"query": {"prefix": {"message": "test"}}}'
curl -XGET 'http://localhost:9200/twitter/tweet/_search?pretty' -d
'{"query": {"prefix": {"message": "test"}}}'
However, if I search for "test ", there are no results:
curl -XPOST 'http://localhost:9200/twitter/tweet/_search?pretty' -d
'{"query": {"prefix": {"message": "test "}}}'
curl -XGET 'http://localhost:9200/twitter/tweet/_search?pretty' -d
'{"query": {"prefix": {"message": "test "}}}'
However again, the same query works fine if put into the URL (using wget
and not curl because curl tries to expand the braces):
wget -O - '
http://localhost:9200/twitter/tweet/_search?{"query":{"prefix":{"message":"test%20"}}}http://localhost:9200/twitter/tweet/_search?{"query":{"prefix":{"message":"test%20"}}}
'
How do I make the queries with "test " work when they are supplied in the
request body?
My Elasticsearch version is 1.1.1.
--
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/e17173c2-7e9d-429f-b36e-e897a695b56e%40googlegroups.comhttps://groups.google.com/d/msgid/elasticsearch/e17173c2-7e9d-429f-b36e-e897a695b56e%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.
--
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/CAHXA0_1xAjxqGHTcT-7dQqEQRWoqLEXwkG5czbOUWNpasFpjdg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.