Stack Overflow Asked by rohini on November 18, 2021
Original Code:
CosmosPagedIterable familiesPagedIterable = container.queryItems(
"SELECT Family.id FROM Family", queryOptions, Family.class);
familiesPagedIterable.iterableByPage(10).forEach(cosmosItemPropertiesFeedResponse -> {
System.out.println("Got a page of query result with " +
cosmosItemPropertiesFeedResponse.getResults().size() + " items(s)"
+ " and request charge of " + cosmosItemPropertiesFeedResponse.getRequestCharge());
System.out.println("Item Ids " + cosmosItemPropertiesFeedResponse
.getResults()
.stream()
.map(Family::getId)
.collect(Collectors.toList()));
});
Above code prints all the entires in the items, what I want is to get the item id present in Family, without any Family model class created in java. Trying to get the items id for all the container present in the database
Please try something like this:
CosmosPagedIterable<String> familiesPagedIterable = container.queryItems("select value c.id from c",queryOptions, String.class);
familiesPagedIterable.iterableByPage(10).forEach(cosmosItemPropertiesFeedResponse -> {
System.out.println("Got a page of query result with " +
cosmosItemPropertiesFeedResponse.getResults().size() + " items(s)"
+ " and request charge of " + cosmosItemPropertiesFeedResponse.getRequestCharge());
System.out.println("Item Ids " + cosmosItemPropertiesFeedResponse
.getResults()
.stream()
.collect(Collectors.toList()));
});
Answered by Steve Zhao on November 18, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP