0

I am trying to implement a completion suggestion for my java application. I've read the documentation but could not find anything on how to implement it using the Java API in Version 5.0.1. (All i found was related to older versions)

this.client.prepareSuggest...

=> does not exist anymore

this.client.prepareSearch... .addSuggestion(csb);

=> does not accept CompletionSuggestionBuilder

This is my maven dependency:

<dependency>
    <groupId>org.elasticsearch.client</groupId>
    <artifactId>transport</artifactId>
    <version>5.0.1</version>
</dependency>

Can anyone provide an example?

1 Answer 1

1

The correct way of doing it is like this:

CompletionSuggestionBuilder csb = SuggestBuilders.completionSuggestion("foo")
    .prefix("prefix");
client().prepareSearch()
    .suggest(new SuggestBuilder().addSuggestion("foo", csb))
Sign up to request clarification or add additional context in comments.

7 Comments

Great! Thank you very much!
Could you also help me on how to specify fuzziness ? I cannot find a setter for that in CompletionSuggestionBuilder => elastic.co/guide/en/elasticsearch/reference/current/…
You can use the overloaded prefix(String, Fuzziness) method for that purpose
@Gibbs you can definitely use the low level RETS client and send your DSL queries.
the high-level client uses the low-level client, so it should be quicker, but you won't really notice a thing.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.