This is not a problem of escape. Always use "match" query. Never use "query_string".
Jörg On Tue, Aug 12, 2014 at 10:50 AM, Tihomir Lichev <[email protected]> wrote: > Does anyone have an idea hot to escape < and > in a query ??? > > 07 август 2014, четвъртък, 18:27:08 UTC+3, Tihomir Lichev написа: > >> Hello, >> I recently discovered very interesting problem >> >> The analyzer is *whitespace:* >> { >> "mappings": { >> "test": { >> "properties": { >> "title": { >> "analyzer": "whitespace", >> "type": "string" >> }, >> "description": { >> "analyzer": "whitespace", >> "type": "string" >> } >> } >> } >> } >> } >> >> >> I have 3 documents with the following content: >> { >> "id": 1, >> "title" : "testing123", >> "description" : "a description" >> } >> { >> "id": 2, >> "title" : "testing >end", >> "description" : "another description" >> } >> { >> "id": 3, >> "title" : "testing <end", >> "description" : "another description" >> } >> >> >> Then I did the following search queries: >> { >> "query": { >> >> "bool": { >> "should": [ >> { >> "query_string": { >> "query": ">end", >> "fields": [ >> "title" >> ] >> } >> } >> ] >> } >> } >> } >> >> RESULT: 3 hits (all docs) - wrong >> EXPLAIN description: "ConstantScore(title:{end TO *]), product of:" >> >> { >> "query": { >> >> "bool": { >> "should": [ >> { >> "query_string": { >> "query": "<end", >> "fields": [ >> "title" >> ] >> } >> } >> ] >> } >> } >> } >> >> RESULT: 3 hits (all docs) - wrong >> EXPLAIN description: "ConstantScore(title:[* TO end}), product of:" >> >> { >> "query": { >> >> "bool": { >> "should": [ >> { >> "query_string": { >> "query": "end", >> "fields": [ >> "title" >> ] >> } >> } >> ] >> } >> } >> } >> >> RESULT: 0 hits (correct!) >> >> I tried to escape "<" and ">" in the query, but no success >> >> Search for < and > in the elasticsearch and lucene docs - also no luck. >> Obvoiusly they are recognized as range operators, but I want to use them >> also as normal text symbols. >> Is there any way to escape them properly ? >> >> >> -- > 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/9fee6a55-b3ff-4192-9329-4e5f6fead45e%40googlegroups.com > <https://groups.google.com/d/msgid/elasticsearch/9fee6a55-b3ff-4192-9329-4e5f6fead45e%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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAKdsXoEfEhK%3D-XWyy8kqRqN6_ESNGa7U1uuowDmm37_0%2BkXo0Q%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
