Reputation: 164
I use the nGram plugin for my queries but also I want to add the Phonetic Analysis to the same field on my mapping.
I'm trying the following settings, and it works well with the nGram plugin but I don't know how can I add the dbl_metaphone
analyzer on my mapping.
curl -XPUT "127.0.0.1/index" -d'
{
"settings": {
"analysis": {
"filter": {
"nGram_filter": {
"type": "nGram",
"min_gram": 2,
"max_gram": 20,
"token_chars": [
"letter",
"digit",
"punctuation",
"symbol"
]
},
"dbl_metaphone": {
"type": "phonetic",
"encoder": "double_metaphone"
}
},
"analyzer": {
"nGram_analyzer": {
"type": "custom",
"tokenizer": "whitespace",
"filter": [
"lowercase",
"asciifolding",
"nGram_filter"
]
},
"whitespace_analyzer": {
"type": "custom",
"tokenizer": "whitespace",
"filter": [
"lowercase",
"asciifolding"
]
},
"dbl_metaphone": {
"tokenizer": "standard",
"filter": "dbl_metaphone"
}
}
}
},
"mappings": {
"books": {
"_all": {
"analyzer": "nGram_analyzer",
"search_analyzer": "whitespace_analyzer"
},
"properties": {
"descripcion":{
"type": "string",
"analyzer": "nGram_analyzer",
"search_analyzer": "whitespace_analyzer"
},
"categories":{
"type": "nested",
"properties": {
"nombre":{
"type": "string",
"analyzer": "nGram_analyzer",
"search_analyzer": "whitespace_analyzer"
}
}
}
}
}
}
}'
Any help?
Upvotes: 0
Views: 55
Reputation: 18864
My solution to this problem would be to have a multi field to analyze the data in different ways. Then to combine the results at query time you could use a bool query with either should
or must
clauses.
So the mapping would look something like this:
"mappings": {
"books": {
"properties": {
"descripcion": {
"type": "string",
"analyzer": "nGram_analyzer",
"search_analyzer": "whitespace_analyzer"
"fields": {
"metaphone": {
"type": "string",
"analyzer": "dbl_metaphone"
}
}
}
}
}
}
And a query would have to use the descripcion
and descripcion.metaphone
fields. The field descripcion.metaphone
is the one analyzed with the dbl_metaphone
analyzer.
Does this solve your problem?
Upvotes: 1
Reputation: 19253
Combo analyzer is an option here. It allows you to specify multiple analyzers and it clubs the tokens from both the analyzers are the end result.
Upvotes: 0