你的浏览器禁用了JavaScript, 请开启后刷新浏览器获得更好的体验!
输入关键字进行搜索
搜索:
没有找到相关结果
kennywu76 - Wood
赞同来自: caochuansong
PUT my_index { "settings": { "analysis": { "analyzer": { "my_analyzer": { "tokenizer": "my_tokenizer" } }, "tokenizer": { "my_tokenizer": { "type": "ngram", "min_gram": 2, "max_gram": 2, "token_chars": [ "letter", "digit" ] } } } }, "mappings": { "company": { "properties": { "name": { "type": "text", "analyzer": "my_analyzer" } } } } }
POST my_index/_search { "query": { "match": { "name": "试1" } } } { "took": 1, "timed_out": false, "_shards": { "total": 5, "successful": 5, "failed": 0 }, "hits": { "total": 1, "max_score": 0.62191015, "hits": [ { "_index": "my_index", "_type": "company", "_id": "AVyCIZF6MEN3nKM0AYMh", "_score": 0.62191015, "_source": { "name": "上海测试1有限公司" } } ] } }
POST my_index/_search { "query": { "match": { "name": "测试1" } } } { "took": 1, "timed_out": false, "_shards": { "total": 5, "successful": 5, "failed": 0 }, "hits": { "total": 3, "max_score": 0.78549397, "hits": [ { "_index": "my_index", "_type": "company", "_id": "AVyCIZF6MEN3nKM0AYMh", "_score": 0.78549397, "_source": { "name": "上海测试1有限公司" } }, { "_index": "my_index", "_type": "company", "_id": "AVyCIarGMEN3nKM0AYMj", "_score": 0.28582606, "_source": { "name": "上海测试有限公司" } }, { "_index": "my_index", "_type": "company", "_id": "AVyCIZzCMEN3nKM0AYMi", "_score": 0.16358379, "_source": { "name": "上海测试2有限公司" } } ] } }
caochuansong
赞同来自:
要回复问题请先登录或注册
2 个回复
kennywu76 - Wood
赞同来自: caochuansong
例如:
写入测试数据:
上海测试有限公司
上海测试1有限公司
上海测试2有限公司
用match query搜索"试1",只会match一条
如果搜索“测试1”,则会match所有3条,不过匹配度高的评分较高,排序在前。
caochuansong
赞同来自: