Noel Yap
Noel Yap

Reputation: 19768

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?

Upvotes: 10

Views: 6619

Answers (2)

Pär Eriksson
Pär Eriksson

Reputation: 367

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

;)

Looks like the implementation is the same..

Upvotes: 3

Noel Yap
Noel Yap

Reputation: 19768

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

Upvotes: 20

Related Questions