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

[BUG] SearchRequest with suggest property is throwing error #771

Closed
itshuien opened this issue Dec 18, 2023 · 5 comments · Fixed by #812
Closed

[BUG] SearchRequest with suggest property is throwing error #771

itshuien opened this issue Dec 18, 2023 · 5 comments · Fixed by #812
Labels
bug Something isn't working

Comments

@itshuien
Copy link

What is the bug?

A clear and concise description of the bug.

An error is thrown when making a SearchRequest with suggest

org.opensearch.client.opensearch._types.OpenSearchException: Request failed: [x_content_parse_exception] [1:61] [completion] unknown field [prefix]

How can one reproduce the bug?

Steps to reproduce the behavior.

SearchRequest searchRequest = new SearchRequest.Builder()
        .index(index)
        .suggest(suggest -> suggest.suggesters("completion_text",
                FieldSuggester.of(f -> f.completion(c -> c.field("text").prefix("abc")))))
        .build();

openSearchClient.search(searchRequest, SearchResponse.class);

What is the expected behavior?

A clear and concise description of what you expected to happen.

The search request should succeed.

What is your host/environment?

Operating system, version.

OpenSearch Java Client: 2.8.0
Java: 17

Do you have any screenshots?

If applicable, add screenshots to help explain your problem.

Do you have any additional context?

Add any other context about the problem.

@itshuien itshuien added bug Something isn't working untriaged labels Dec 18, 2023
@dblock
Copy link
Member

dblock commented Dec 18, 2023

Want to turn this into a failing test?

@dblock dblock removed the untriaged label Dec 18, 2023
@itshuien
Copy link
Author

Want to turn this into a failing test?

Sorry, I'm not sure if I understand what you mean 😅

@dblock
Copy link
Member

dblock commented Dec 20, 2023

Write an integration test in this project that makes this API call and fails. This way we know what to fix.

@VachaShah
Copy link
Collaborator

@itshuien I think the issue is that prefix needs to be added to the FieldSuggester, this FieldSuggester will contain the type of suggester. An example of the usage from the samples: https://github.com/opensearch-project/opensearch-java/blob/main/samples/src/main/java/org/opensearch/client/samples/Search.java#L140-L143. I think this should solve your issue.

@VachaShah
Copy link
Collaborator

On a separate note, the prefix parameter needs to be removed from the completion suggester. I will pick this up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants