Skip to content
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

GroupOptions is not working [DATASOLR-290] #410

Open
spring-projects-issues opened this issue Apr 4, 2016 · 1 comment
Open

GroupOptions is not working [DATASOLR-290] #410

spring-projects-issues opened this issue Apr 4, 2016 · 1 comment
Assignees
Labels
in: core type: bug

Comments

@spring-projects-issues
Copy link

@spring-projects-issues spring-projects-issues commented Apr 4, 2016

Yogya H opened DATASOLR-290 and commented

In order to group results by personId I used the following code

Criteria cb =   PatientIndexCriteriaBuilder.getCriteriaBuilder(searchCriteria);
Query search = new SimpleQuery(cb);

Field field = new SimpleField("personId");
SimpleQuery groupQuery = new SimpleQuery(new SimpleStringCriteria("*:*"));
GroupOptions groupOptions = new GroupOptions()
.addGroupByField(field)
.addGroupByQuery(search);
groupQuery.setGroupOptions(groupOptions);

GroupPage<PatientIndex> results= solrTemplate.queryForGroupPage(search, PatientIndex.class);

The returning result is not group by the person Id.

But instead of using groupoptions If I use the following code, The returning data is properly group by the personId.

Query search = new SimpleQuery(cb);
search.addGroupByField(field);
Page<PatientIndex> results = solrOperations.queryForPage(search, PatientIndex.class);

Affects: 1.5.4 (Gosling SR4)

Reference URL: http://stackoverflow.com/questions/36336816/spring-data-solr-groupoptions-is-not-working

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Oct 4, 2018

Partha commented

I am having a similar issue,

I have defined the group options as below :

 

private GroupOptions getGroupOptions(Pageable page, final String groupBy) {
   final Field groupByField = new SimpleField(groupBy);
   final GroupOptions groupOptions = new GroupOptions().addGroupByField(groupByField);
   groupOptions.setTotalCount(true);
   groupOptions.setOffset(Long.valueOf(page.getOffset()).intValue());
   groupOptions.setLimit(Long.valueOf(page.getPageSize()).intValue());
   return groupOptions;
}


// In the called function, I do :

final GroupOptions groupOptions = getGroupOptions(page, groupBy);
GroupPage<MyDocument> groupPage =
			 solrTemplate.queryForGroupPage(solrCollection, searchQuery,
			 MyDocument.class);
// I get : Page 1 of 0 UNKNOWN instances in the log.

If i follow the suggestion of Yogya, I am able to group by. Looks like your GroupOptions feature and GroupPage, are broken

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

No branches or pull requests

2 participants