我似乎无法弄清楚如何让 elasticsearch(通过 pyes 访问)来搜索复数/单数术语。例如,当我进入 Monkies 时,我想返回带有 Belt 的结果。我看过Elasticsearch 没有返回单数/复数匹配,但似乎无法理解。这是一些 curl 语句
curl -XDELETE localhost:9200/myindex
curl -XPOST localhost:9200/myindex -d '
{"index":
{ "number_of_shards": 1,
"analysis": {
"filter": {
"myfilter": {
"type" : "porter_stem",
"language" : "English"
}
},
"analyzer": {
"default" : {
"tokenizer" : "nGram",
"filter" : ["lowercase", "myfilter"]
},
"index_analyzer" : {
"tokenizer" : "nGram",
"filter" : ["lowercase", "myfilter"]
},
"search_analyzer" : {
"tokenizer" : "nGram",
"filter" : ["lowercase", "myfilter"]
}
}
}
}
}
}'
curl -XPUT localhost:9200/myindex/mytype/_mapping -d '{
"tweet" : {
"date_formats" : ["yyyy-MM-dd", "dd-MM-yyyy"],
"properties" : {
"user": {"type":"string"},
"post_date": {"type": "date"},
"message" : {"type" : "string", "analyzer": "search_analyzer"}
}
}}'
curl -XPUT 'http://localhost:9200/myindex/mytype/1' -d '{
"user" : "kimchy",
"post_date" : "2009-11-15T14:12:12",
"message" : "belt knife is a cool thing"
}'
curl -XPUT 'http://localhost:9200/myindex/mytype/2' -d '{
"user" : "alwild",
"post_date" : "2009-11-15T14:12:12",
"message" : "second message with nothing else"
}'
curl -XGET localhost:9200/myindex/mytype/_search?q=message:belts
我已经到了搜索腰带给我一些结果的地步……但现在它给出的结果太多了。我该怎么做才能让它只返回一个带有“腰带”的条目?