定义了edgeNGram,搜索仅对完整的单词有效,而对标记不起作用

时间:2018-09-14 06:34:31

标签: elasticsearch

我将es 6.4用作AWS服务。这是我的映射-

{
  "settings": {
    "analysis": {
      "analyzer": {
        "my_analyzer": {
          "type": "custom",
          "tokenizer": "my_tokenizer"
        }
      }
    },
    "tokenizer": {
      "my_tokenizer": {
        "type": "edge_ngram",
        "min_gram": 3,
        "max_gram": 20,
        "token_chars": [
          "letter"
        ]
      }
    }
  },
  "mappings": {
    "tsetse": {
      "properties": {
        "id": {
          "type": "integer"
        },
        "user_id": {
          "type": "integer"
        },
        "description": {
          "type": "text",
          "analyzer": "my_analyzer"
        },
        "type": {
          "type": "integer"
        }
      }
    }
  }
}

该索引有一条记录,描述为“地球上最大的性能”。当我尝试搜索时,它总是可以用完整的字词显示-地球或性能。不返回关于great或perf的结果。我想念什么?

在此使用EdgeNGram更新了映射`

{
  "settings": {
    "analysis": {
      "filter": {
        "autocomplete_filter": {
          "type": "edge_ngram",
          "min_gram": 1,
          "max_gram": 20
        }
      },
      "analyzer": {
        "my_analyzer": {
          "type": "custom",
          "tokenizer": "standard",
          "filter": [
            "lowercase",
            "autocomplete_filter"
          ]
        }
      }
    }
  },
  "mappings": {
    "tsetse": {
      "properties": {
        "id": {
          "type": "integer"
        },
        "user_id": {
          "type": "integer"
        },
        "description": {
          "type": "text",
          "analyzer": "my_analyzer"
        },
        "type": {
          "type": "integer"
        }
      }
    }
  }
}

`

要点脚本-https://gist.github.com/swati-patil/0b1cea74fc52b1b96d44ad239ad2580d 谢谢,

0 个答案:

没有答案