Skip to content

Add test cases for dynamic_templates mappings #443

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

reta
Copy link
Collaborator

@reta reta commented Apr 6, 2025

Description

Add test cases for dynamic_templates mappings

Issues Resolved

Followup on #437

Check List

  • New functionality includes testing.
    • All tests pass
  • New functionality has been documented.
    • New functionality has javadoc added
  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@reta reta requested a review from dlvenable as a code owner April 6, 2025 18:20
Copy link
Contributor

@rursprung rursprung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this test only tests whether it can create the index with the mapping but does not verify whether that actually works. as shown in #437 it currently adds something which it shouldn't and thus searching documents fails afterwards. i think it'd be great if this test here could cover that (in which case it'd currently fail until opensearch-project/opensearch-java#1513 gets resolved)

Signed-off-by: Andriy Redko <[email protected]>
@reta
Copy link
Collaborator Author

reta commented Apr 7, 2025

this test only tests whether it can create the index with the mapping but does not verify whether that actually works. as shown in #437 it currently adds something which it shouldn't and thus searching documents fails afterwards. i think it'd be great if this test here could cover that (in which case it'd currently fail until opensearch-project/opensearch-java#1513 gets resolved)

@rursprung updated the tests but I have troubles reproducing the failure, could you please help me to craft it properly? Thank you.

@rursprung
Copy link
Contributor

hm, interestingly enough i just created a test case which fails for both ORHLC and OSC (which isn't the bug which i had reported) 😅:

in DynamicTemplatesContextBaseTests:

    @Test
    void shouldCreateDynamicTemplateWithDots() {
        IndexOperations indexOperations = operations.indexOps(SampleDynamicTemplatesEntity.class);
        assertThat(indexOperations.createWithMapping()).isTrue();

        operations.save(new SampleDynamicTemplatesEntity(Map.of("A.B", "Smith")));
        assertThat(operations.search(Query.findAll(), SampleDynamicTemplatesEntity.class).get().count()).isEqualTo(1L);
    }

the only change compared to shouldCreateDynamicTemplateOne is that i replaced "John" with "A.B" which is reasonable and to be expected?

since i can't push to your branch i created #446 to show a test which actually fails. note that you have to remove the @DisabledIf annotation to see the failing test

@reta
Copy link
Collaborator Author

reta commented Apr 14, 2025

the only change compared to shouldCreateDynamicTemplateOne is that i replaced "John" with "A.B" which is reasonable and to be expected?

@rursprung No, this is not supported: the values with dots are not accepted to object fields (but to nested or flattened fields), traced it back to https://www.elastic.co/guide/en/elasticsearch/reference/2.4/dots-in-names.html

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

Successfully merging this pull request may close these issues.

2 participants