如何进行elasticsearch 前缀匹配的代码分析
导读:本文共1550.5字符,通常情况下阅读需要5分钟。同时您也可以点击右侧朗读,来听本文内容。按键盘←(左) →(右) 方向键可以翻页。
摘要: curl -XDELETE 'http://localhost:9200/ess/';curl -XPOST 'http://localhost:9200/ess' -d '{ "analysis": { "filter": { "autoco... ...
目录
(为您整理了一些要点),点击可以直达。- (2): "analysis": {
- (3): "filter": {
- (4): "autocomplete_
- (5): "type":
- (6): "min_gram&qu
- (7): "max_gram&qu
- (9): }
- (10): },
- (11): "analyzer":
- (12): "autocomplete&
- (13): "type":
- (15): "filter"
- (16): "lowercase
- (17): "autocompl
- (18): ]
- (19): },
- (21): "tokenizer&qu
- (23): "lowercase
- (24): ]
- (25): }
- (26): }
- (27): }
- (31): "ess": {
- (32): "properties":
- (33): "id": {
- (34): "type" : &qu
- (35): },
- (36): "fullname": {
- (37): "type" : &qu
- (38): },
- (39): "allname": {
- (40): "type" : &qu
- (41): "analyzer":
- (43): }
- (44): }
- (45): }
- (51):'
- (54):'
- (57):'
- (59): "query": {
- (60): "match": {
- (61): "allname":
- (62): }
- (63): }
curl -XDELETE 'http://localhost:9200/ess/';
curl -XPOST 'http://localhost:9200/ess' -d '{
"analysis": {
"filter": {
"autocomplete_filter": {
"type": "edge_ngram",
"min_gram": 1,
"max_gram": 20,
"token_chars": ["whitespace"]
}
},
"analyzer": {
"autocomplete": {
"type": "custom",
"tokenizer": "whitespace",
"filter": [
"lowercase",
"autocomplete_filter"
]
},
"postsearch": {
"tokenizer": "keyword",
"filter": [
"lowercase"
]
}
}
}
}'
curl -XPOST 'http://localhost:9200/ess/ess/_mapping' -d'
{
"ess": {
"properties": {
"id": {
"type" : "long"
},
"fullname": {
"type" : "string"
},
"allname": {
"type" : "string",
"analyzer": "autocomplete",
"search_analyzer": "postsearch"
}
}
}
}'
curl 'localhost:9200/ess/_analyze?pretty=1&analyzer=autocomplete' -d 'zs zhangsan zsan zhangs 张三 张s zns'
curl 'localhost:9200/ess/_analyze?pretty=1&analyzer=postsearch' -d 'Z'
curl -XPOST http://localhost:9200/ess/ess/1 -d'
{"fullname":"张三" , "allname" : "zs zhangsan zsan zhangs 张三 张s zns" }
'
curl -XPOST http://localhost:9200/ess/ess/2 -d'
{"fullname":"张三风" , "allname" : "zsf zhangsanfeng zsanfeng zhangsf 张三 三风 张sf znsf" }
'
curl -XPOST http://localhost:9200/ess/ess/3 -d'
{"fullname":"李三风" , "allname" : "lsf lisanfeng lsanfeng lsf 李三 三风 李s lsf" }
'
curl -XGET 'http://localhost:9200/ess/_search?pretty' -d '{
"query": {
"match": {
"allname": "张S"
}
}
}'
如何进行elasticsearch 前缀匹配的代码分析的详细内容,希望对您有所帮助,信息来源于网络。