4
I’m registering some objects of the kind:
[{
nome: "bom_atendimento",
chaves: ["bem atendido", "atendimento bom"]
},
{
nome: "ruim_atendimento",
chaves: ["pessimo atendimento", "atendimento ruim"]
}]
I need these keys to be identified in a text.
Input text examples / output I need:
1 - "This service was bad"
outworking:
{
nome: "ruim_atendimento",
chaves: ["pessimo atendimento", "atendimento ruim"]
}
2 - "Today I was well attended"
outworking:
{
nome: "bom_atendimento",
chaves: ["bem atendido", "atendimento bom"]
}
How I’m indexing:
{
"settings": {
"analysis": {
"analyzer": {
"custom_keyword_analyzer": {
"type": "custom",
"tokenizer": "standard",
"filter": [
"asciifolding",
"lowercase",
"custom_stopwords",
"custom_stemmer"
]
},
"custom_shingle_analyzer": {
"type": "custom",
"tokenizer": "whitespace",
"filter": [
"custom_stopwords",
"custom_stemmer",
"asciifolding",
"lowercase",
"custom_shingle"
]
}
},
"filter": {
"custom_stemmer": {
"type": "stemmer",
"name": "brazilian"
},
"custom_stopwords": {
"type": "stop",
"stopwords": [
"a",
"as",
"o",
"os",
"fui"
],
"ignore_case": true
},
"custom_shingle": {
"type": "shingle",
"min_shingle_size": 2,
"output_unigrams": false,
"output_unigrams_if_no_shingles": true
}
}
}
},
"mappings": {
"meutipo": {
"properties": {
"nome": { "type": "keyword" },
"chaves": {
"type": "text",
"analyzer": "custom_keyword_analyzer",
"search_analyzer": "custom_shingle_analyzer"
}
}
}
}
}
My research: { index: 'meuindex', type: 'meutipo',
body:{
"query": {
"match": { "chaves": "texto"} }
}
}
}
I’m not getting results. When I remove custom_shingle
filter custom_shingle_analyzer
, any text that has "attendance" returns the two ES records.
I need it to only have results if the text contains at least one expression exactly equal to a chave
registered in ES. In my example:
To get the result:
{
nome: "bom_atendimento",
chaves: ["bem atendido", "atendimento bom"]
}
the text should contain "well served" or "good service".
What’s the best way to do this? Using synonyms and Shingle?
Elasticsearch version: 5.1.2
I don’t quite understand. It can describe a little better how it is indexed in ES, at least 3 examples of how the query (input) would be and how the answer should be (output)?
– Tom Melo
@Tommelo edited my question. It became clearer?
– Thiago R.