ElasticSearch打分机制学习

创建一个索引

curl -s -XPUT 'http://localhost:9200/gino_test/' -d '{
  "mappings": {
    "tweet": {
      "properties": {
        "text": {
          "type": "string",
          "term_vector": "with_positions_offsets_payloads",
          "store" : true,
          "analyzer" : "fulltext_analyzer"
         },
         "fullname": {
          "type": "string",
          "term_vector": "with_positions_offsets_payloads",
          "analyzer" : "fulltext_analyzer"
        }
      }
    }
  },
  "settings" : {
    "index" : {
      "number_of_shards" : 1,
      "number_of_replicas" : 0
    },
    "analysis": {
      "analyzer": {
        "fulltext_analyzer": {
          "type": "custom",
          "tokenizer": "whitespace",
          "filter": [
            "lowercase",
            "type_as_payload"
          ]
        }
      }
    }
  }
}'

插入测试数据:

_index _type _id text fullname
gino_test tweet 1 hello world gino zhang
gino_test tweet 2 gino like world cup gino li
gino_test tweet 3 my cup jsper li

简单情况:单字段匹配打分

POST http://192.168.102.216:9200/gino_test/_search
{
  "explain": true,
  "query": {
    "match": {
      "text": "my cup"
    }
  }
}

查询结果: score_example1.json https://drivenotepad.github.io/app/?state={%22action%22:%22open%22,%22ids%22:[%220B4dv03yigoV2VjFIbEI3ZFQwRlk%22]}

打分分析:
https://drive.google.com/open?id=1RZhu9j9NNy30KNYd4qwQ9b6o5utdnyq0yqzDhdW_5uo
example1_1.jpg

https://drive.google.com/open?id=1B4fVZLiGvHAIrKH_zk7jTSVHjcXQC1Byd8tKXbNswck

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值