Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error deserializing Phrase Suggester #338

Closed
andreluiz1987 opened this issue Jul 8, 2022 · 1 comment
Closed

Error deserializing Phrase Suggester #338

andreluiz1987 opened this issue Jul 8, 2022 · 1 comment

Comments

@andreluiz1987
Copy link

andreluiz1987 commented Jul 8, 2022

Java API client version

8.3.1

Java version

11

Elasticsearch Version

8.3

Problem description

Hi!!

I'm implementing the Phrase Suggester in the Java API Client, the error below occurs:

Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is co.elastic.clients.json.JsonpMappingException: Error deserializing co.elastic.clients.elasticsearch.core.search.PhraseSuggest: co.elastic.clients.json.UnexpectedJsonEventException: Unexpected JSON event 'START_ARRAY' instead of '[START_OBJECT, KEY_NAME]' (JSON path: suggest['phrase#did_you_mean'][0].options) (line no=1, column no=2585, offset=-1)] with root cause

Code Java

Map<String, FieldSuggester> map = new HashMap<>();
    map.put("did_you_mean", FieldSuggester.of(fs -> fs.phrase(p ->
            p.maxErrors(2.0).size(5).field("title.suggest")
        )
    ));
    Suggester suggester = Suggester.of(sg -> sg
        .suggesters(map)
        .text(term)
    );
    builder.suggest(suggester);

I think that is it an API bug.

@swallez
Copy link
Member

swallez commented Jul 13, 2022

This has been fixed in #348.

@swallez swallez closed this as completed Jul 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants