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

Not possible to create queries that uses InnerHits with storedFields. #780

Closed
brentam opened this issue Dec 22, 2023 · 1 comment · Fixed by #781
Closed

Not possible to create queries that uses InnerHits with storedFields. #780

brentam opened this issue Dec 22, 2023 · 1 comment · Fixed by #781
Labels
bug Something isn't working

Comments

@brentam
Copy link
Contributor

brentam commented Dec 22, 2023

What is the bug?

in the InnerHits.Builder the serialiser/deserialiser is generating/expecting the wrong json field name for "stored_fields".
It is actually using "stored_field" (singular).

Thus, Is not possible to create queries that uses InnerHits with storedFields.

Any queries constructed with inner_hits + stored_field will fail to execute in OpenSearch due to the fact that "stored_field" (singular) is not valid.

Worse still, when generating request from Json, the "stored_fields" field is not deserialised. So nothing about those fields are found in the final json sent to OpenSearch.

How can one reproduce the bug?

this test will fail.

    @Test
    public void testInnerHitStoredFields() {
        JsonpMapper mapper = new JsonbJsonpMapper();
        InnerHits hits = InnerHits.of((it) -> it.storedField(List.of("field1", "field2")));
        StringWriter sw = new StringWriter();
        JsonProvider provider = mapper.jsonProvider();
        JsonGenerator generator = provider.createGenerator(sw);
        mapper.serialize(hits, generator);
        generator.close();
        assertTrue(sw.toString().contains("stored_fields"));
    }

What is the expected behavior?

The builder should generate "stored_fields" instead of "store_field"

What is your host/environment?

macOS 14.1.2

Do you have any screenshots?

not needed

Do you have any additional context?

Well, the name of the serialized field is wrong, no extra context is needed I guess...

@brentam
Copy link
Contributor Author

brentam commented Dec 23, 2023

Created PR #781

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.

2 participants