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

Faceted queries not returning total for individual field values [DATASOLR-166] #288

spring-projects-issues opened this issue May 21, 2014 · 5 comments


Copy link

@spring-projects-issues spring-projects-issues commented May 21, 2014

Jega A opened DATASOLR-166 and commented

I am working on a POC for using Solr with spring-data-solr and spring-data-rest-mvc

I have my repository defined as follows:

// Repository 
public interface ContractRepository extends SolrCrudRepository<Contract, String> {

	@Facet( fields = "product")
	FacetPage<Contract> searchAllFieldsWithFacets(@Param("searchStr") String searchStr, Pageable page);

// Query that is actually going to Solr when "searchAllFieldsWithFacets?searchStr=Canada" is executed
// Result of the query (showing only the last part of the result)
"page" : {
    "size" : 20,
    "totalElements" : 2479,
    "totalPages" : 124,
    "number" : 0

Notice how the facet result appears just as one number under "totalElements". For some reason it is not being expanded into the various values under the faceted field (i.e "product").

//The same query executed directly in the Solr Admin UI returns the correct results

"facet_counts": {
    "facet_queries": {},
    "facet_fields": {
      "product": [
    "facet_dates": {},
    "facet_ranges": {}

Why is the individual product count missing in the spring-data-solr query?

Affects: 1.2 RC1 (Dijkstra)

Copy link

@spring-projects-issues spring-projects-issues commented May 21, 2014

Christoph Strobl commented

I cannot quite reproduce the issue. FacetPage contains one Page<FacetFieldEntry per term. FacetFieldEntry then holds the actual value (eg. Consulting) and the according valueCount (eg. 836).

FacetPage<Contract> facetPage = repo.searchAllFieldsWithFacets("Canada", new PageRequest(0,10));
for(FacetFieldEntry entry : facetPage.getFacetResultPage("product")) {
	// eg.: Consulting, Software, Training

	// eg.: 836, 827, 816

Could you give the above snippet a spin - maybe I am missing something here

Copy link

@spring-projects-issues spring-projects-issues commented May 23, 2014

Jega A commented

Created a quick test to run through the code you provided. That seems to work. Here is the output

Beginning facetsTest()

Value: Consulting
Count: 835
Value: Software
Count: 827
Value: Training
Count: 816

Ending facetsTest()

Accessing facets with this code surely seems to work. However, still not sure why the json results that return from the REST call does not have the break up!!

Copy link

@spring-projects-issues spring-projects-issues commented May 29, 2014

Jega A commented

I did some additional tests and the results when accessed directly using spring-data-solr seems to work. It is only when the results are converted back to JSON object where data seems to be missing. Will try and see if I can get some help from the spring-data-rest-webmvc group

Copy link

@spring-projects-issues spring-projects-issues commented Jan 7, 2021

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

Copy link

@spring-projects-issues spring-projects-issues commented Jan 14, 2021

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants