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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to