When performing a suggest search against a completion field whose search_analyzer contains a synonym_set, Elasticsearch returns a 500 response with a null pointer exception.
This behavior does not occur when using inline synonyms, or synonym_path, and the synonym_set behaves as expected when using the _analyze endpoint.
Expected:suggest searches on completion fields that utilize a synonym set return a non-error response, and the suggest prefix is correctly tokenized according to the rules of the synonym set.
Actual: a 500 response is returned, with a null_pointer_exception and a reason of Cannot invoke "org.elasticsearch.index.analysis.AnalyzerComponents.getCharFilters()" because "components" is null
Steps to Reproduce
Create a synonym set with an arbitrary number of synonyms ranging from 0 - n.
Create an index with the following details:
A filter containing:
A type of synonym or synonym_graph
"updateable": "true"
A synonym_set using the name of the previously created synonym set
An analyzer containing:
A filter with the previously created filter
`"tokenizer": "standard"
A completion field containing:
A search_analyzer using the name of the previously created analyzer
Create a document in this index with an arbitrary value for the previously created completion field
Make a request to the _search endpoint of the index using a suggest query with an arbitrary prefix
The following should produce a working example of the issue:
# Create synonym set
PUT _synonyms/test_synonyms
{
"synonyms_set": [
{
"id": "test-1",
"synonyms": "jerry, gary"
}
]
}
# (Re)create index
DELETE test_synonym_index
PUT test_synonym_index
{
"settings": {
"analysis": {
"filter": {
"filter-synonym-completion": {
"type": "synonym_graph",
"updateable": "true",
"synonyms_set": "test_synonyms"
}
},
"analyzer": {
"analyzer-completion-search": {
"filter": [
"lowercase",
"filter-synonym-completion"
],
"tokenizer": "standard"
}
}
}
},
"mappings": {
"properties": {
"titleCompletion": {
"type": "completion",
"search_analyzer": "analyzer-completion-search"
}
}
}
}
# Create a document
PUT test_synonym_index/_doc/1?refresh
{
"titleCompletion" : {
"input": "Gary is the title of this document"
}
}
# Attempt a suggestion search
POST test_synonym_index/_search?filter_path=suggest
{
"suggest": {
"title": {
"prefix": "jerry",
"completion": {
"field": "titleCompletion"
}
}
}
}
It is worth noting that during index creation, if the synonym filter is created using in-line or synonyms_path, and updateable is omitted, the suggest search will work as expected:
Elasticsearch Version
8.13.2
Installed Plugins
No response
Java Version
bundled
OS Version
Elastic Cloud
Problem Description
When performing a
suggest
search against acompletion
field whosesearch_analyzer
contains asynonym_set
, Elasticsearch returns a500
response with a null pointer exception.This behavior does not occur when using inline synonyms, or
synonym_path
, and thesynonym_set
behaves as expected when using the_analyze
endpoint.Expected:
suggest
searches on completion fields that utilize a synonym set return a non-error response, and the suggest prefix is correctly tokenized according to the rules of the synonym set.Actual: a
500
response is returned, with anull_pointer_exception
and a reason ofCannot invoke "org.elasticsearch.index.analysis.AnalyzerComponents.getCharFilters()" because "components" is null
Steps to Reproduce
Create a synonym set with an arbitrary number of synonyms ranging from 0 -
n
.Create an index with the following details:
synonym
orsynonym_graph
"updateable": "true"
synonym_set
using the name of the previously created synonym setfilter
with the previously created filtercompletion
field containing:search_analyzer
using the name of the previously created analyzerCreate a document in this index with an arbitrary value for the previously created completion field
Make a request to the
_search
endpoint of the index using asuggest
query with an arbitraryprefix
The following should produce a working example of the issue:
It is worth noting that during index creation, if the synonym filter is created using in-line or
synonyms_path
, andupdateable
is omitted, thesuggest
search will work as expected:Logs (if relevant)
The exact error response from Elastic is as follows: