es--es分词的一些分析技巧
查看某个字段的分词结果
POST /index/tyhpe/id/_termvectors?fields=fields_name
例如:http://localhost:9200/prod_membermodel/membermodel/80/_termvectors?fields=nickName
_analyze查看分词结果
前缀搜索
{
"query": {
"bool": {
"should": [
{
"match_phrase_prefix": {
"nickName": {
"query": "10040",
"slop": 5,
"max_expansions": 20
}
}
},
{
"match_phrase_prefix": {
"userId": {
"query": "10040",
"slop": 5,
"max_expansions": 20
}
}
},
{
"match_phrase_prefix": {
"nickName.stand": {
"query": "10040",
"slop": 5,
"max_expansions": 20
}
}
},
{
"multi_match": {
"query": "10040",
"type": "most_fields",
"fields": [
"nickName",
"nickName.stand",
"userId"
]
}
}
]
}
},
"sort": {
"_score": {
"order": "desc"
},
"video": {
"order": "desc"
}
},
"size": 12,
"from": 0
}
通配符搜索
{
"query": {
"bool": {
"should": [
{
"wildcard": {
"nickName":"*kura*"
},
},
{
"wildcard": {
"userId": "*kura*"
},
},
{
"wildcard": {
"nickName.stand": "*kura*"
},
},
{
"multi_match": {
"query": "kura",
"type": "most_fields",
"fields": [
"nickName",
"nickName.stand",
"userId"
]
}
}
]
}
},
"sort": {
"_score": {
"order": "desc"
},
"video": {
"order": "desc"
}
},
"size": 12,
"from": 0
}