您可以将stemmer 与percolate query 一起使用
添加一个包含索引数据、映射、搜索查询和搜索结果的工作示例
索引映射:
{
"settings": {
"analysis": {
"analyzer": {
"my_analyzer": {
"tokenizer": "whitespace",
"filter": [
"stemmer"
]
}
}
}
},
"mappings": {
"properties": {
"tags": {
"type": "text",
"analyzer": "my_analyzer"
},
"query": {
"type": "percolator"
}
}
}
}
索引数据:
{
"query": {
"match_phrase": {
"tags": {
"query": "blue waters",
"analyzer": "my_analyzer"
}
}
}
}
{
"query": {
"match_phrase": {
"tags": {
"query": "extra blue water",
"analyzer": "my_analyzer"
}
}
}
}
{
"query": {
"match_phrase": {
"tags": {
"query": "blue water",
"analyzer": "my_analyzer"
}
}
}
}
搜索查询:
{
"query": {
"percolate": {
"field": "query",
"document": {
"tags": "blue water"
}
}
}
}
搜索结果:
"hits": [
{
"_index": "67671916",
"_type": "_doc",
"_id": "3",
"_score": 0.26152915,
"_source": {
"query": {
"match_phrase": {
"tags": {
"query": "blue waters",
"analyzer": "my_analyzer"
}
}
}
},
"fields": {
"_percolator_document_slot": [
0
]
}
},
{
"_index": "67671916",
"_type": "_doc",
"_id": "1",
"_score": 0.26152915,
"_source": {
"query": {
"match_phrase": {
"tags": {
"query": "blue water",
"analyzer": "my_analyzer"
}
}
}
},
"fields": {
"_percolator_document_slot": [
0
]
}
}
]