curl -XPUT http://xx.xx.xxx.xx:9200/abcccc -d ‘
{
“settings” : {
“analysis” : {
“analyzer” : {
“my_ngram_analyzer” : {
“tokenizer” : “my_ngram_tokenizer”,
“char_filter”:[“html_strip”]
}
},
“tokenizer” : {
“my_ngram_tokenizer” : {
“type” : “nGram”,
“min_gram”:1,
“max_gram”:1,
“token_chars”:[
“letter”,
“digit”,
“punctuation”,
“symbol”
]
}
}
}
}
}’
curl -XPUT http://xx.xx.xxx.xx:9200/abcccc/biglog/_mapping -d ‘
{
“biglog” : {
“_all”: {“enabled”: false},
“properties” : {
“tt” : {
“type” : “string”,”analyzer” : “my_ngram_analyzer”}
}
}
}’
http://xx.xx.xxx.xx:9200/abcccc/_analyze?pretty=true&analyzer=my_ngram_analyzer&text=123456789
curl -XPOST http://xx.xx.xxx.xx:9200/abcccc/biglog/ -d ‘{“tt” : “123456789”}’
curl -XPOST http://xx.xx.xxx.xx:9200/abcccc/biglog/_search -d ‘
{
“query”: {
“match_phrase”: {
“tt”: {
“query”: “6”,
“slop”: 1, //slop 定义的是关键词之间隔多少未知单词
“analyzer”: “my_ngram_analyzer”
}
}
}
}
作者:匠心零度
来源:CSDN
原文:https://blog.csdn.net/lirenzuo/article/details/70245063
版权声明:本文为博主原创文章,转载请附上博文链接!