I need to be able to perform Completion Suggest queries that are context dependent.
When executing the query below:
POST synonym_file_test/_search
{
"_source": "suggest",
"suggest": {
"my-suggest": {
"prefix": "N",
"completion": {
"field": "general_suggest",
"size": 3,
"skip_duplicates": false,
"contexts" : {
"typ_context" : ["1"]
}
}
}
}
}
#returns the following error
{
"error": {
"root_cause": [
{
"type": "null_pointer_exception",
"reason": """Cannot invoke "org.elasticsearch.index.analysis.AnalyzerComponents.getCharFilters()" because "components" is null"""
}
],
}
}
Although the analyzer seems to be working fine when using it like below:
GET synonym_file_test/_analyze
{
"analyzer": "search_analyzer",
"text": "N"
}
#returns the following
{
"tokens": [
{
"token": "norra",
"start_offset": 0,
"end_offset": 1,
"type": "SYNONYM",
"position": 0
},
{
"token": "n",
"start_offset": 0,
"end_offset": 1,
"type": "<ALPHANUM>",
"position": 0
}
]
}
The following is the config (mapping/settings) I am using for this purpose:
PUT synonym_file_test
{
"mappings: {
"properties": {
"general_suggest": {
"type": "completion",
"search_analyzer": "search_analyzer",
"preserve_separators": true,
"preserve_position_increments": true,
"max_input_length": 50,
"contexts" : [
{
"name" : "typ_context",
"type" : "category",
"path" : "typ"
}
]
}
}
},
"settings": {
"index":{
"analysis": {
"analyzer": {
"index_analyzer": {
"tokenizer" : "standard",
"filter" : [
"lowercase"
]
},
"search_analyzer": {
"tokenizer": "standard",
"filter": [
"lowercase",
"synonym_filter"
]
}
},
"filter":{
"synonym_filter": {
"type":"synonym_graph",
"synonyms_path": "analyze/synonyms.txt",
"updateable": true
}
}
}
}
}
}
I have looked in to the documentation regarding both the Synonyms and the Completion Suggesters
Synonym token filter | Elasticsearch Guide [8.8] | Elastic
and
Suggesters | Elasticsearch Guide [8.5] | Elastic
also done alot of looking around on the forum and third party docs to find a fix for it without ant progress, hence the post.
Thankful for an input on this, regards