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] "Misspelling" on setting maxAnalyzedOffset from Highlight.Builder #553

Closed
alexsandrospecht opened this issue Jul 4, 2023 · 3 comments
Labels
bug Something isn't working untriaged

Comments

@alexsandrospecht
Copy link

What is the bug?

We have a "misspelling" on the maxAnalyzedOffset setting from Highlight.Builder. here

When we set the maxAnalyzedOffset in the Highlight.Builder the setting that is added on the json is max_analyzed_offset (looks right but it's not), when we execute this query we get the following error:

    "error": {
        "root_cause": [
            {
                "type": "x_content_parse_exception",
                "reason": "[36:9] [highlight] unknown field [max_analyzed_offset] did you mean [max_analyzer_offset]?"
            }
        ],
        "type": "x_content_parse_exception",
        "reason": "[36:9] [highlight] unknown field [max_analyzed_offset] did you mean [max_analyzer_offset]?"
    },
    "status": 400
}

The max_analyzed_offset setting is from ElasticSearch, on OpenSearch the correct setting is max_analyzer_offset.

How can one reproduce the bug?

final var openSearchRequest = new SearchRequest.Builder()
                    .trackTotalHits(t -> t.enabled(true))
                    .index(indexReadAlias)
                    .query(queryBuilder.buildQuery())
                    .highlight(builder -> builder
                            .preTags(preTag)
                            .postTags(postTag)
                            .maxAnalyzedOffset(MAX_ANALYZER_OFFSET) <- Just need to set this 
                            .fields(Document.TITLE_FIELD, buildHighlightField())
                            .fields(Document.CONTENT_FIELD, buildHighlightField())
                            .fields(Document.URL_FIELD, buildHighlightField()))
                    .size(queryBuilder.querySize())
                    .from(queryBuilder.startFrom())
                    .sort(sortBuilder.buildSort())
                    .build();

What is the expected behavior?

Update the api to match the OpenSearch Highlight setting max_analyzer_offset

What is your host/environment?

Amazon OpenSearch service 2.5 managed by AWS.

Do you have any additional context?

StackTrace:

19:00:59.853 [http-nio-auto-1-exec-1] ERROR o.a.c.c.C.[.[.[.[dispatcherServlet] - Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed: org.opensearch.client.opensearch._types.OpenSearchException: Request failed: [x_content_parse_exception] [1:637] [highlight] unknown field [max_analyzed_offset] did you mean [max_analyzer_offset]?] with root cause
org.opensearch.client.opensearch._types.OpenSearchException: Request failed: [x_content_parse_exception] [1:637] [highlight] unknown field [max_analyzed_offset] did you mean [max_analyzer_offset]?
	at org.opensearch.client.transport.rest_client.RestClientTransport.getHighLevelResponse(RestClientTransport.java:278)
	at org.opensearch.client.transport.rest_client.RestClientTransport.performRequest(RestClientTransport.java:144)
	at org.opensearch.client.opensearch.OpenSearchClient.search(OpenSearchClient.java:1302)
	...
@alexsandrospecht alexsandrospecht added bug Something isn't working untriaged labels Jul 4, 2023
schmittjoaopedro added a commit to schmittjoaopedro/opensearch-java that referenced this issue Jul 5, 2023
… name to match with the one introduced in OpenSearch 2.2.0

Signed-off-by: Joao Pedro Schmitt <[email protected]>
schmittjoaopedro added a commit to schmittjoaopedro/opensearch-java that referenced this issue Jul 5, 2023
… name to match with the one introduced in OpenSearch 2.2.0

Signed-off-by: Joao Schmitt <[email protected]>
schmittjoaopedro added a commit to schmittjoaopedro/opensearch-java that referenced this issue Jul 5, 2023
… name to match with the one introduced in OpenSearch 2.2.0

Signed-off-by: Joao Schmitt <[email protected]>
schmittjoaopedro added a commit to schmittjoaopedro/opensearch-java that referenced this issue Jul 5, 2023
… name to match with the one introduced in OpenSearch 2.2.0

Signed-off-by: Joao Schmitt <[email protected]>
schmittjoaopedro added a commit to schmittjoaopedro/opensearch-java that referenced this issue Jul 5, 2023
… name to match with the one introduced in OpenSearch 2.2.0

Signed-off-by: Joao Schmitt <[email protected]>
schmittjoaopedro added a commit to schmittjoaopedro/opensearch-java that referenced this issue Jul 5, 2023
… name to match with the one introduced in OpenSearch 2.2.0

Signed-off-by: Joao Schmitt <[email protected]>
schmittjoaopedro added a commit to schmittjoaopedro/opensearch-java that referenced this issue Jul 5, 2023
… name to match with the one introduced in OpenSearch 2.2.0

Signed-off-by: Joao Schmitt <[email protected]>
reta pushed a commit that referenced this issue Jul 5, 2023
…h the one introduced in OpenSearch 2.2.0 (#557)

Signed-off-by: Joao Schmitt <[email protected]>
@szczepanczykd
Copy link
Collaborator

szczepanczykd commented Jul 5, 2023

@schmittjoaopedro You can use SNAPSHOT here:
https://aws.oss.sonatype.org/content/repositories/snapshots/org/opensearch/client/opensearch-java/2.6.0-SNAPSHOT/

An example maven config:

<properties>
        <opensearch.java.version>2.6.0-20230705.163620-8</opensearch.java.version>
</properties>
        <dependency>
            <groupId>org.opensearch.client</groupId>
            <artifactId>opensearch-java</artifactId>
            <version>${opensearch.java.version}</version>
        </dependency>
<repositories>
        <repository>
            <id>opensearch snapshots</id>
            <url>https://aws.oss.sonatype.org/content/repositories/snapshots</url>
        </repository>
</repositories>

@schmittjoaopedro
Copy link
Contributor

Thanks

@alexsandrospecht
Copy link
Author

Thank you

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

Successfully merging a pull request may close this issue.

3 participants