Hyphens in query_string


(avasilenko) #1

Hello,

Is it possible to consider hyphen (separate by spaces) in query_string as a
hyphen, rather than lucene "minus" (like explained in lucene
http://lucene.apache.org/java/3_4_0/queryparsersyntax.html#-)? E.g.
consider it as "minus", when it's followed by the word, not space.

Reproduce:
Consider following mapping -
https://gist.github.com/1404391#file_mapping.json and content
https://gist.github.com/1404391#file_content.json . Address contains
hyphen, but it's cut down by standard tokenizer.
Now try to query, using the same analyzer -
https://gist.github.com/1404391#file_query.json with no luck. IMHO it's
because this hyphen is treated as lucene "minus". Escaping text with quotes
gives proper results -
https://gist.github.com/1404391#file_query_with_quotes.json .

Regards,
Alexandr Vasilenko


(Karussell) #2

I think the lucene query string parser works as this, why not
implement it yourself on the client side?

Do you need the query_string query at all - why not use the term query
(and index:no) if you always query the full string (or describe what
you need)?

Regards,
Peter.

On 29 Nov., 12:00, Alex Vasilenko aa.vasile...@gmail.com wrote:

Hello,

Is it possible to consider hyphen (separate by spaces) in query_string as a
hyphen, rather than lucene "minus" (like explained in lucenehttp://lucene.apache.org/java/3_4_0/queryparsersyntax.html#-)?E.g.
consider it as "minus", when it's followed by the word, not space.

Reproduce:
Consider following mapping -https://gist.github.com/1404391#file_mapping.jsonand contenthttps://gist.github.com/1404391#file_content.json. Address contains
hyphen, but it's cut down by standard tokenizer.
Now try to query, using the same analyzer -https://gist.github.com/1404391#file_query.jsonwith no luck. IMHO it's
because this hyphen is treated as lucene "minus". Escaping text with quotes
gives proper results -https://gist.github.com/1404391#file_query_with_quotes.json.

Regards,
Alexandr Vasilenko


(avasilenko) #3

Hello Peter,

Yes, I need query_string, because it's used as search input in client. Term
and exact match is preferred, but client doesn't support it now and I was
looking for solution on server side, specifically in ES.
But anyway I force client devs to use term instead :).

Thanks,
Alexandr Vasilenko

2011/11/30 Karussell tableyourtime@googlemail.com

I think the lucene query string parser works as this, why not
implement it yourself on the client side?

Do you need the query_string query at all - why not use the term query
(and index:no) if you always query the full string (or describe what
you need)?

Regards,
Peter.

On 29 Nov., 12:00, Alex Vasilenko aa.vasile...@gmail.com wrote:

Hello,

Is it possible to consider hyphen (separate by spaces) in query_string
as a
hyphen, rather than lucene "minus" (like explained in lucenehttp://
lucene.apache.org/java/3_4_0/queryparsersyntax.html#-)?E.g.
consider it as "minus", when it's followed by the word, not space.

Reproduce:
Consider following mapping -
https://gist.github.com/1404391#file_mapping.jsonand contenthttps://
gist.github.com/1404391#file_content.json. Address contains
hyphen, but it's cut down by standard tokenizer.
Now try to query, using the same analyzer -
https://gist.github.com/1404391#file_query.jsonwith no luck. IMHO it's
because this hyphen is treated as lucene "minus". Escaping text with
quotes
gives proper results -
https://gist.github.com/1404391#file_query_with_quotes.json.

Regards,
Alexandr Vasilenko


(system) #4