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
Mixing NativeQuery with CriteriaQuery and a Criteria with GeoLocation fails #2840
Comments
Had a first look at the sample repo; alas there is no explicit Spring Data Elasticsearch configuration, so I cannot just plug in an intercepting proxy to see what's going over the line. I will need to set this up in a configurable way. |
BTW, If you are using Elasticsearch 8.12, be aware that Elasticsearch broke the communication at one place between the client and the server, the problem comes from the server side, so it will happen with a client lib of 8.11 as well, see #2836 and the issues linked there |
Ok, had some time to debug this now. A So we need to fix that for a |
backported to 5.2.x and 5.1.x |
Thx for fixing! |
The fix indeed works, but only when aggregation is not used, as the filtering added by criteria, for example,
|
I see, that only comes up when using the |
Hi @sothawo The fix works for the SearchHits, but does not work for Aggregations. I tested the new code with spring-data-elasticsearch 5.3.0-M2. I added another test as a showcase in the repository Github, Test demonstrating the issue it adds this to the NativeQuery:
and this to the test:
I persist 4 documents and want to find 3 documents. After the upgrade to 5.3.0-M2, the result contains the expected 3 results, but the aggregation still contains all 4 documents. I can also create a new ticket, if this would be easier, please tell me what you prefer. |
That is what I wrote in my last comment: the geolocation filter is set as a post filter and so it does affect the query but not the aggregation. There is already #2857 to see if this can be changed, so there is no need for a new issue. |
Thx for the explanation! |
Mixing a NativeQuery and a CriteriaQuery fails, when using Criteria with geoLocation.
Version: Spring Data ElasticSearch 5.2.2
Spring Boot Version: 3.2.2
ElasticSearch Version: 8.12.0
Github, Service demonstrating the issue
Github, Test demonstrating the issue
delivers the expected result -> only one document is found
fails, both documents are found. It also fails with bounding box queries. Everything that is geo-related.
If I run the critieriaQuery directly, without nesting it in NativeQuery, it works. Sometimes this nesting is necessary, e.g. when using Aggregations, but in general we write the Queries in CriteriaQuery.
Issue: Using a CriteriaQuery as base for the NativeQueryBuilder fails when using a geo based query. Other critiera work (e.g. Term).
The text was updated successfully, but these errors were encountered: