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] Query displayed in details page does not match the input query #30

Open
deshsidd opened this issue Nov 12, 2024 · 3 comments
Open
Labels
bug Something isn't working

Comments

@deshsidd
Copy link
Collaborator

What is the bug?

Query displayed in details page does not match the input query and has additional attributes (probably defaults).

Ran the following query:

{
  "query": {
    "match": {
      "name": "John"
    }
  }
}

Query details page shows the following:
image

Is this the expected behavior?

How can one reproduce the bug?

Steps to reproduce the behavior.

What is the expected behavior?

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

What is your host/environment?

Operating system, version.

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.

@deshsidd deshsidd added bug Something isn't working untriaged labels Nov 12, 2024
@dblock dblock removed the untriaged label Dec 2, 2024
@dblock
Copy link
Member

dblock commented Dec 2, 2024

[Catch All Triage - 1, 2, 3]

@dzane17
Copy link
Collaborator

dzane17 commented Jan 16, 2025

I do not see a straightforward solution for this. Every *QueryBuilder class has it's own set of "default" fields which are present for every instance of that class. For the match query example in this github issue, the fields (query, operator, prefix_length, max_extensions, fuzzy_trans...) are defined in the MatchQueryBuilder() constructor regardless of if they were specified in the original request.

    public MatchQueryBuilder(StreamInput in) throws IOException {
        super(in);
        fieldName = in.readString();
        value = in.readGenericValue();
        operator = Operator.readFromStream(in);
        prefixLength = in.readVInt();
        maxExpansions = in.readVInt();
        fuzzyTranspositions = in.readBoolean();
        lenient = in.readBoolean();
        zeroTermsQuery = MatchQuery.ZeroTermsQuery.readFromStream(in);
        // optional fields
        analyzer = in.readOptionalString();
        minimumShouldMatch = in.readOptionalString();
        fuzzyRewrite = in.readOptionalString();
        fuzziness = in.readOptionalWriteable(Fuzziness::new);
        cutoffFrequency = in.readOptionalFloat();
        autoGenerateSynonymsPhraseQuery = in.readBoolean();
    }

ref: https://github.com/opensearch-project/OpenSearch/blob/main/server/src/main/java/org/opensearch/index/query/MatchQueryBuilder.java#L135-L152

To obtain the bare search request, we cannot rely on SearchSourceBuilder passed via SearchPhaseContext.

@deshsidd
Copy link
Collaborator Author

Thanks @dzane17 , looks like we will need core changes here to either intercept the query or make sure we have a way to get toString() without including default values. Will likely target this post 2.19

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

No branches or pull requests

3 participants