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

Facet pivot not working? [DATASOLR-193] #312

Closed
spring-projects-issues opened this issue Aug 25, 2014 · 6 comments
Closed

Facet pivot not working? [DATASOLR-193] #312

spring-projects-issues opened this issue Aug 25, 2014 · 6 comments

Comments

@spring-projects-issues
Copy link

@spring-projects-issues spring-projects-issues commented Aug 25, 2014

Jega A opened DATASOLR-193 and commented

I am trying to get Solr facet fields working with pivots. The following is the Solr query I am trying execute via Spring Data Solr

q=*:*
sort=action_ts DESC
facet=true
facet.field=user
facet.pivot=user,action

The direct Solr query returns results as expected as shown below (only a small portion is shown below):

"facet_fields":{
      "user":[
        "alpha@mycompany.com",15,
        "delta@mycompany.com",15,
        "echo@mycompany.com",15,
        "golf@mycompany.com",15,
        "hotel@mycompany.com",15,
        "india@mycompany.com",15,
        "juliett@mycompany.com",15,
        "november@mycompany.com",15,
        "oscar@mycompany.com",15,
        "foxtrot@mycompany.com",14]},
    "facet_dates":{},
    "facet_ranges":{},
    "facet_pivot":{
      "user,action":[{
          "field":"user",
          "value":"alpha@mycompany.com",
          "count":15,
          "pivot":[{
              "field":"action",
              "value":"add",
              "count":7},
            {
              "field":"action",
              "value":"download",
              "count":3},
            {
              "field":"action",
              "value":"login",
              "count":2},
            {
              "field":"action",
              "value":"search",
              "count":2},
            {
              "field":"action",
              "value":"logout",
              "count":1}]},
	<Rest of the output truncated ...>	

I am trying to reproduce the same with SDS (version: 1.2.2.RELEASE)

In my repository I have


@Query(value = "(?0)", filters="(?1)" )
@Facet( fields = {"user"}, pivotFields={"user,action"})
FacetPage<UserAction> findAllWithFiltersAndFacets(String query, String filters, Pageable page);

This query completes fine and the facet results appear as expected (see below):

"facetResultPages": [
        {
            "content": [
                {
                    "valueCount": 15,
                    "value": "alpha@mycompany.com",
                    "field": {
                        "name": "user"
                    },
                    "key": {
                        "name": "user"
                    }
                },
                {
                    "valueCount": 15,
                    "value": "delta@mycompany.com",
                    "field": {
                        "name": "user"
                    },
                    "key": {
                        "name": "user"
                    }
                },
                {
                    "valueCount": 15,
                    "value": "echo@mycompany.com",
                    "field": {
                        "name": "user"
                    },
                    "key": {
                        "name": "user"
                    }
                },
<Rest of the output truncated ...>

However, the facet pivot output does not have any results (see below):

"facetPivotFields": [
        {
            "fields": [
                {
                    "name": "user"
                },
                {
                    "name": "action"
                }
            ],
            "name": "user,action"
        }
    ],
    

No pivot information appears in the output. I have also attached the entire output with this issue.

I also tried the alternate way to specify the pivots:

@Query(value = "(?0)", filters="(?1)" )
@Facet( fields = {"user"}, pivots={ @Pivot({"user", "action"}) } )
FacetPage<UserAction> findAllWithFiltersAndFacets(String query, String filters, Pageable page);

The above method also produced the same incorrect results.

What am I missing here?

Thanks


Affects: 1.2.2 (Dijkstra SR2)

Attachments:

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Aug 26, 2014

Christoph Strobl commented

The query created seems to be a valid one - at least the one I tested with. It would be helpful if you could provide the query sent to Solr when executing findAllWithFiltersAndFacets. Just grab it from your Solr log or set:

<logger name="org.springframework.data.solr.core.SolrTemplate" level="DEBUG"/>

Maybe its one of the filters interfering

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Aug 26, 2014

Jega A commented

Here is the information from the Solr log in the raw format

select?q=%28*%3A*%29&start=0&rows=1&fq=%28tenant_id%3ADSX+AND+action%3A%28add+OR+download+OR+search+%29%29&sort=action_ts+desc&facet=true&facet.mincount=1&facet.limit=10&facet.field=user&facet.pivot=user%2Caction&wt=javabin&version=2

The same with decoded applied

select?q=(*:*)&start=0&rows=1&fq=(tenant_id:DSX AND action:(add OR download OR search ))&sort=action_ts desc&facet=true&facet.mincount=1&facet.limit=10&facet.field=user&facet.pivot=user,action&wt=javabin&version=2

Note that if I take the above query and simply append it to a query going directly to Solr then the Solr results look right (i.e., the pivot information is available). So I am thinking that Solr is doing the right thing however, along the way before being returned to the browser the information is lost.
I am returning the information back from a service using FacetPage<T>.

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Sep 25, 2014

Christoph Strobl commented

Is there a chance you can craft a testcase reproducing the problem?

BTW how are you returning results back to the browser... spring-data-rest?

@spring-projects-issues
Copy link
Author

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

Francisco Spaeth commented

The invocation of:

getFacetPivotFields()

will returning only the facet pivot fields for a given facet page.

Try

getPivot(PivotField);
// or 
getPivot(String);

those methods shall return a FacetPivotFieldEntry that is the representation of a pivot result.

I just opened DATASOLR-205 in order to document the use of pivot faceting

@spring-projects-issues
Copy link
Author

@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.

@spring-projects-issues
Copy link
Author

@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
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants