我有copy_to正確匹配工作,但我無法正確設置與部分匹配。以下是我的映射/設置和查詢與預期和實際結果。Elasticsearch | copy_to部分搜索
設置:
{
"test": {
"settings": {
"index": {
"analysis": {
"filter": {
"ngram_filter": {
"type": "edge_ngram",
"min_gram": "1",
"max_gram": "15"
}
},
"analyzer": {
"ngram_analyzer": {
"filter": [
"lowercase",
"ngram_filter"
],
"type": "custom",
"tokenizer": "standard"
}
}
},
"number_of_shards": "1",
"number_of_replicas": "1",
}
}
}
}
映射:
POST /test/_mapping/name
{
"name": {
"properties": {
"vital": {
"properties": {
"first": {
"type": "string",
"copy_to": "full_name",
"term_vector": "yes",
"analyzer": "ngram_analyzer",
"search_analyzer": "standard"
},
"last": {
"type": "string",
"copy_to": "full_name",
"term_vector": "yes",
"analyzer": "ngram_analyzer",
"search_analyzer": "standard"
},
"full_name": {
"type": "string",
"term_vector": "yes",
"analyzer": "ngram_analyzer",
"search_analyzer": "standard"
}
}
}
}
}
}
POST:
POST /test/name
{
"vital": {
"first": "Tom",
"last": "Doe"
}
}
現在,當我做搜索...
GET /test/name/_search
{
"query": {
"match": {
"full_name": {
"query": "Tom Doe",
"operator": "and"
}
}
}
}
...我找回結果!! Hurrraaaay,但如果我做了搜索....
GET /test/name/_search
{
"query": {
"match": {
"full_name": {
"query": "Tom Do",
"operator": "and"
}
}
}
}
...我回來沒有結果:(我想部分匹配爲FULL_NAME工作,以及作爲另一個不是我能夠成功地因部分匹配的名字和姓氏,只是full_name不起作用,我會怎麼做呢?
還需要什麼? – Val
不,不錯! – emarel