I have copy_to working correctly for exact matches, but I cannot properly configure it with partial matches. Below are my mappings / settings and query with expected and actual results.
:
{
"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",
}
}
}
}
display:
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"
}
}
Now when I do a search ...
GET /test/name/_search
{
"query": {
"match": {
"full_name": {
"query": "Tom Doe",
"operator": "and"
}
}
}
}
... I will return the result! Hurrraaaay, but if I do a search ....
GET /test/name/_search
{
"query": {
"match": {
"full_name": {
"query": "Tom Do",
"operator": "and"
}
}
}
}
... I do not get the result :( I would like the partial match to work for full_name as well. As another, I could not successfully perform the partial match by name and surname. It's just a full_name that doesn't work. How can I do this?