Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the Java API to escape Elasticsearch special characters?

I'm trying to perform the following query with the Java API:

"query": {
  "bool" : {
    "must" : [ {
      "field" : {
        "space-time-id.timestamp" : "2014-03-17T16:57:47.136-07:00"
      }
    } ]
  }
}

This fails presumably because the value has colons (which are special characters). Can someone point me to the Java API that escapes such characters?

like image 492
Noel Yap Avatar asked Mar 18 '14 00:03

Noel Yap


2 Answers

org.apache.lucene.queryparser.classic.QueryParser.escape()

like image 148
Noel Yap Avatar answered Sep 20 '22 17:09

Noel Yap


You can also use org.apache.lucene.queryparser.flexible.standard.QueryParserUtil.escape()

;)

Looks like the implementation is the same..

like image 44
Pär Eriksson Avatar answered Sep 18 '22 17:09

Pär Eriksson