Skip to content

Add inner_hits support to the collapse field in NativeSearchQuery [DATAES-939] #1493

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

Closed
spring-projects-issues opened this issue Sep 29, 2020 · 3 comments · Fixed by #1815
Closed
Labels
in: core Issues in core support type: enhancement A general enhancement

Comments

@spring-projects-issues
Copy link

sothawo opened DATAES-939 and commented

Currently NativeSearchQuery supports a collapse field by accepting a String. This should be extended to also allow to define inner_hits and other parameters (https://www.elastic.co/guide/en/elasticsearch/reference/7.9/collapse-search-results.html#expand-collapse-results)


Reference URL: https://stackoverflow.com/questions/64106687/spring-data-elasticsearch-is-inner-hit-supported-at-root-level-on-query

@spring-projects-issues spring-projects-issues added type: enhancement A general enhancement in: core Issues in core support labels Dec 31, 2020
@saidkilicaslan
Copy link

Hi, is there any workaround to get inner hits with collapse field for now?

@sothawo
Copy link
Collaborator

sothawo commented Jan 5, 2021

NO, this is still an open issue.

@saidkilicaslan
Copy link

I did the workaround.
I'm using JestElasticsearchTemplate as client and I copied NativeQueryBuilder with an extra method:

public ExtendedNativeQueryBuilder withCollapse(CollapseBuilder collapseBuilder){ this.collapseBuilder = collapseBuilder; return this; }

and using the client with the new method.

((JestElasticsearchTemplate) elasticsearchTemplate).query(new ExtendedNativeQueryBuilder() .withIndices("indice").withFilter(QueryBuilders.matchAllQuery()) .withCollapse(new CollapseBuilder("collapse_field").setInnerHits(new InnerHitBuilder("inner_hit_name"))) .build(), extractor);

as a query result, I'm able to retrieve innert_hits inside the JSON object.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core support type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants