Fluent interface does not allow setting of prefix and completion for suggestions
Java API client version
7.17.2
Java version
17.0.2
Elasticsearch Version
7.17.2
Problem description
Per the ES documentation I want to specify a completion and prefix for suggestions: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters.html#querying
POST music/_search?pretty
{
"suggest": {
"song-suggest": {
"prefix": "nir",
"completion": {
"field": "suggest"
}
}
}
}
In the fluent interface, I'd expect to be able to do something like this:
new Suggester.Builder().suggesters("song-suggest", s -> s.prefix("nir").completion(c->c.field("suggest")))
However, you can only use either prefix() or completion(), but not both. (The existence of FieldSuggester.Kind.Prefix suggests to me that "prefix" is incorrectly used as a type of suggester, rather than as a parameter for the completion suggester.)
The following does compile (and makes logical sense to me), however, it leads to a runtime exception:
new Suggester.Builder().suggesters("song-suggest", s -> s.completion(c->c.prefix("nir").field("suggest")))
The runtime exception in question:
co.elastic.clients.elasticsearch._types.ElasticsearchException: [es/search] failed: [x_content_parse_exception] [1:179] [completion] unknown field [prefix]
Update: the issue still exists in 7.17.5.
We're still forced to use the deprecated RHLC because of this bug (among others).
Due to the package collisions, that means we're still unable to use a version of Java later than Java 8.
To the maintainers: are you aware that you're blocking the technological modernisation of your consumers?
Closing this as it was fixed in newer versions of the client, thanks for the feedback and sorry for the wait!