Custom analyzer not working


(Faiz Halde) #1

I'm using the below mapping where the payload.body field will contain json as a string. i want to get rid of all the braces, quotes colons e.t.c from the json and leave out only the keys [the values will be empty string all the time]. but for some reason the char mapping is not working

e.g. {"query": {match_all: ''}} returns querymatch_all

{
  "order": 0,
  "template": "custom_stats*",
  "settings": {
    "index": {
      "analysis": {
        "analyzer": {
          "query_logging_analyzer": {
            "char_filter": [
              "json_entites"
            ],
            "tokenizer": "whitespace"
          }
        },
        "char_filter": {
          "json_entites": {
            "type": "mapping",
            "mappings": [
              "{=> ",
              "}=> ",
              "'=> ",
              "\"=> ",
              ":=> ",
              ",=> ",
              "[=> ",
              "]=> "
            ]
          }
        }
      }
    }
  },
  "mappings": {
    "logs": {
      "properties": {
        "payload": {
          "properties": {
            "body": {
              "index": "not_analyzed",
              "type": "string",
              "fields": {
                "features": {
                  "analyzer": "query_logging_analyzer",
                  "type": "string"
                }
              }
            }
          }
        }
      }
    }
  },
  "aliases": {}
}

#2

No needs to create a mapping filter for that.
The standard analyzer will exclude all these special characters!

GET index/_analyze
{
  "text": "{\"query\": {match_all: ''}}",
  "field": "body"
}

(system) #3

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