ElasticSearch学习笔记-邻近匹配搜索记录

ElasticSearch版本:elasticsearch-7.3.0

环境准备:

curl -H "Content-Type: application/json" -XPUT 'http://192.168.0.1:9200/article/' -d '
{
  "settings": {
    "analysis": {
      "analyzer": {
        "shingle_analyzer": {
          "type": "custom",
          "tokenizer": "ik_smart",
          "filter": [
            "shingle_filter"
          ]
        }
      },
      "filter": {
        "shingle_filter": {
          "type": "shingle",
          "min_shingle_size": 2,
          "max_shingle_size": 4,
          "output_unigrams": false
        }
      }
    }
  },
  "mappings": {
    "dynamic": "strict",
    "_source": {
      "excludes": [
        "id"
      ]
    },
    "properties": {
      "id": {
        "type": "keyword"
      },
      "title": {
        "analyzer": "ik_smart",
        "type": "text",
        "fields": {
          "raw": {
            "type": "keyword"
          },
          "shingle": {
            "type": "text",
            "analyzer": "shingle_analyzer"
          }
        }
      },
      "publish_time": {
        "type": "date",
        "format": "yyyy-MM-dd HH:mm:ss"
      }
    }
  }
}
'
curl -H "Content-Type: application/json" -XPOST 'http://192.168.0.1:9200/article/_doc/1' -d '
{
    "id": "1",
    "title": "周杰伦、林俊杰、罗志祥、王力宏、潘玮柏、蔡依林、孙燕姿、梁静茹一同参加颁奖典礼",
    "publish_time": "2019-08-22 17:48:16"
}
'
curl -H "Content-Type: application/json" -XPOST 'http://192.168.0.1:9200/article/_doc/2' -d '
{
    "id": "2",
    "title": "周杰伦、林俊杰、罗志祥、王力宏、潘玮柏一同参加颁奖典礼",
    "publis

你可能感兴趣的:(ElasticSearch,elasticsearch,临近匹配,slot,shingle,boost)