elasticsearch:自定义char_filter不替换空格

时间:2018-07-03 13:05:22

标签: elasticsearch

我正在使用以下映射,其中payload.body字段将包含json作为字符串。我想删除所有花括号,用json引号冒号e.t.c,仅保留键[值始终都是空字符串]。但由于某种原因,字符映射无法正常工作

例如{"query": {match_all: ''}}返回querymatch_all。它应该返回query match_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": {}
} 

0 个答案:

没有答案