Get the App
SLTechnology News&Howtos  ›  Development  › 

How to analyze the Code of elasticsearch prefix matching

Shulou Source: shulou.com Published: 2022-06-02 03:37:07 10月02日 Update

Today, the editor will show you how to analyze the code of elasticsearch prefix matching. The knowledge points in the article are introduced in great detail. Friends who think it is helpful can browse the content of the article with the editor, hoping to help more friends who want to solve this problem to find the answer to the problem. Follow the editor to learn more about "how to analyze the code of elasticsearch prefix matching".

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 Zhang San s zns'

Curl 'localhost:9200/ess/_analyze?pretty=1&analyzer=postsearch'-d 'Z'

Curl-XPOST http://localhost:9200/ess/ess/1-d'

{"fullname": "Zhang San", "allname": "zs zhangsan zsan zhangs Zhang San s zns"}

'

Curl-XPOST http://localhost:9200/ess/ess/2-d'

{"fullname": "Zhang Sanfeng", "allname": "zsf zhangsanfeng zsanfeng zhangsf Zhang Sanfeng Zhang sf znsf"}

'

Curl-XPOST http://localhost:9200/ess/ess/3-d'

{"fullname": "Li Sanfeng", "allname": "lsf lisanfeng lsanfeng lsf Li Sanfeng Li's lsf"}

'

Curl-XGET 'http://localhost:9200/ess/_search?pretty'-d' {

"query": {

"match": {

"allname": "Zhang S"

}

}

}'

Thank you for your reading, the above is the whole content of "how to analyze the code of elasticsearch prefix matching". Friends who learn to learn to do it quickly. I believe that the editor will certainly bring you better quality articles. Thank you for your support to the website!

Tags: Zhang San code prefixes analysis friends content articles knowledge questions help that is more come on knowledge points answers websites learning support browsing Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi Shulou Tech Info macOS vpn MariaDB