Skip to content

Support different routing for each id in multiget #1954

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
mateog5 opened this issue Oct 7, 2021 · 3 comments · Fixed by #1956
Closed

Support different routing for each id in multiget #1954

mateog5 opened this issue Oct 7, 2021 · 3 comments · Fixed by #1956
Assignees
Labels
type: enhancement A general enhancement

Comments

@mateog5
Copy link

mateog5 commented Oct 7, 2021

Multiget doesn't support different routing for each id

public Flux<MultiGetItem> multiGet(Query query, Class clazz, IndexCoordinates index)
-->
private List<MultiGetRequest.Item> getMultiRequestItems(Query searchQuery, Class<?> clazz, IndexCoordinates index)

for (String id : searchQuery.getIds()) {
   MultiGetRequest.Item item = new MultiGetRequest.Item(indexName, id);

  if (searchQuery.getRoute() != null) {
	item = item.routing(searchQuery.getRoute());
  }
....

Currently is only possible to set same routing for all ids

GET index-search/_mget
{
"docs": [
{
"_type": "_doc",
"_id": "xxxx",
"routing": "routingForXXXX, routingForYYYY"
},
{
"_type": "_doc",
"_id": "yyyy",
"routing": "routingForXXXX, routingForYYYY"

}

]
}

Should be possible to set different routing for each id

GET index-search/_mget
{
"docs": [
{
"_type": "_doc",
"_id": "xxxx",
"routing": "routingForXXX"
},
{
"_type": "_doc",
"_id": "yyyy",
"routing": "routingForYYYY"

}

]
}

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Oct 7, 2021
@sothawo
Copy link
Collaborator

sothawo commented Oct 7, 2021

For this we need to introduce something like a IdWithRouting which contains an id and a routing value and add the possibility to set these on a Query. When building the request these values can then be used to build the get request with different routing values for the ids.

@sothawo sothawo added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Oct 7, 2021
@frnandu
Copy link
Contributor

frnandu commented Oct 8, 2021

I'm also needing this for our project, so +1 for quick implementation

@sothawo sothawo self-assigned this Oct 9, 2021
@sothawo sothawo changed the title multiget different routing for each id Support different routing for each id in multiget Oct 9, 2021
sothawo added a commit that referenced this issue Oct 9, 2021
@sothawo sothawo added this to the 4.3 RC1 (2021.1.0) milestone Oct 9, 2021
@sothawo
Copy link
Collaborator

sothawo commented Oct 9, 2021

implemented it and added a helper method to create the query:

Query query = Query.multiGetQueryWithRouting(
  Arrays.asList(
    new Query.IdWithRouting(ID_1, ROUTING_1),
    new Query.IdWithRouting(ID_2, ROUTING_2),
    new Query.IdWithRouting(ID_3, ROUTING_3)
    )
);

List<MultiGetItem<RoutingEntity>> multiGetItems = operations.multiGet(query, RoutingEntity.class);

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

Successfully merging a pull request may close this issue.

4 participants