Query_string containing the "/" character

Hello,
does anyone know why I'm getting the following error when trying to search for a string that contains the "/" character? It is not listed in the Lucene special characters (and even trying to escape it doesn't help).
Thank you

Search:

"query": {
  "query_string": {
    "query": "2593-0200/92-1",

Error:

{
  "error": {
    "root_cause": [
      {
        "type": "query_shard_exception",
        "reason": "Failed to parse query [2593-0200/92-1]",
        "index_uuid": "WW-lh_mKT7ewuqL6lMUCdA",
        "index": "jurisprudencia-decisoes"
      }
    ],
    "type": "search_phase_execution_exception",
    "reason": "all shards failed",
    "phase": "query",
    "grouped": true,
    "failed_shards": [
      {
        "shard": 0,
        "index": "jurisprudencia-decisoes",
        "node": "aS_7gmiHRcO5s4XCkkg4Zw",
        "reason": {
          "type": "query_shard_exception",
          "reason": "Failed to parse query [2593-0200/92-1]",
          "index_uuid": "WW-lh_mKT7ewuqL6lMUCdA",
          "index": "jurisprudencia-decisoes",
          "caused_by": {
            "type": "parse_exception",
            "reason": "Cannot parse '2593-0200/92-1': Lexical error at line 1, column 15.  Encountered: <EOF> after : \"/92-1\"",
            "caused_by": {
              "type": "token_mgr_error",
              "reason": "Lexical error at line 1, column 15.  Encountered: <EOF> after : \"/92-1\""
            }
          }
        }
      }
    ]
  },
  "status": 400
}

Ok, but it is a reerved character for Elasticsearch

I changed my query to "query": "982\\-0200\\/11\\-9" but it now it fails with:

      "caused_by": {
        "type": "number_format_exception",
        "reason": "For input string: \"982-0200/11-9\""
      }

https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html#_reserved_characters

A couple of things ...

  1. it worked for query string 2593-0200/92-1 by double escaping ... 2593-0200\\/92-1.
  2. Can you use text query via match etc instead of query_string? It worked for me even without escaping.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.