Lax
Lax

Reputation: 1167

Field name convention

I want to use field name with bracket , for example: distance(a). the indexing work fine, but when I query:

GET /search
{
   "query":
       {
         "query_string":"distance(a):*"
       }
}

I got error. in field without bracket it's work fine. Someone know how can I use field name with bracket? Thanks

Upvotes: 1

Views: 708

Answers (1)

fylie
fylie

Reputation: 1715

Okay, so ( is a reserved character in Elasticsearch and to use it in a query you'll have to escape it. A list of reserved characters can be found here. So normally you could just escape it with \, but in order for the escape character to get though the REST API you have to double escape it with \\.

I just tested the following query in my sandbox:

{
  "query": {
    "query_string": {
      "query": "distance\\(a\\):*"
    }
  }
}

Upvotes: 2

Related Questions