I am indexing the documents from a SQL table and there are two fields 'parent_sentence' and 'parent_context' which are primarily used for search.
I am building synonym and 'search-as-you-type'/Partial search on both of those fields. While i am able to build analyzers for the said capabilities, I am unable to get desirable results.
My analyzers are such:
PUT diabetes/
{
"settings": {
"analysis": {
"filter": {
"synonym_filter" : {
"type" : "synonym",
"synonyms" : "synonyms.txt"
},
"autocomplete_filter" : {
"type": "edge_ngram",
"min_gram": 4,
"max_gram": 10
}
},
"analyzer": {
"synonym_analyzer" : {
"tokenizer" : "standard",
"filter" : ["lowercase","synonym_filter"]
},
"autocomplete_analyzer" : {
"tokenizer" : "standard",
"filter" : ["lowercase","synonym_filter"]
}
}
}
}
}
And the corresponding mapping is as follows:
PUT diabetes/_mapping
{
"properties": {
"parent_context" : {
"type" : "text",
"analyzer": "autocomplete_analyzer",
"fields": {
"syn" : {
"type" : "text",
"analyzer" : "synonym_analyzer"
},
"keyword" : {
"type" : "keyword"
}
}
},
"parent_sentence" : {
"type" : "text",
"analyzer": "autocomplete_analyzer",
"fields": {
"syn" : {
"type" : "text",
"analyzer" : "synonym_analyzer"
},
"keyword" : {
"type" : "keyword"
}
}
}
}
}
When I query 'depre' (i am looking to get results containing word 'depression'), i get the following:
Query:
GET diabetes/_search
{
"query": {
"match": {
"parent_context": {
"query": "depre",
"analyzer": "standard"
}
}
}
}
Result:
{
"took" : 0,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 0,
"relation" : "eq"
},
"max_score" : null,
"hits" : [ ]
}
}