Dario
Dario

Reputation: 53

pivot facet query does not show nested result

I want to use pivoted facet query with solr to get counts of documents by specific 'type' in each 'region'. I run the following query:

http://localhost:8983/solr/alfresco/select?facet.pivot=ns:region,ns:type&facet=true&indent=on&q=TYPE:ns\:caseFile&rows=0&start=0&wt=json

I expect to see number documents of specific 'type' in each 'region'. But I get 'region' counts only:

  ....

"_pivot_mappings_": {
"ns:region,ns:type": "text@s__lt@{http://xxx.eu/model/1.0}region,text@s__lt@{http://xxx.eu/model/1.0}type"
},

"facet.pivot": "ns:region,ns:type",
...

  "facet_counts": {
    "facet_intervals": {},
    "facet_pivot": {
      "ns:region,ns:type": [
        {
          "field": "ns:region",
          "count": 479,
          "value": "{en}hk"
        },
        {
          "field": "ns:region",
          "count": 120,
          "value": "{en}gk"
        },
        {
          "field": "ns:region",
          "count": 5,
          "value": "{en}oc"
        },
        {
          "field": "ns:region",
          "count": 2,
          "value": "{en}dep"
        },
      ]
    },
    "facet_queries": {},
    "facet_fields": {},
    "facet_heatmaps": {},
    "facet_ranges": {}
  },

Pivot facets are documented to produce the results I expect, but I was unable to get nested counts, like it was shown here.

Are there any limitations in document model or index itself that prevent getting results I expect? Or is the query wrong? Is there anything I can check?

Upvotes: 0

Views: 212

Answers (2)

Dario
Dario

Reputation: 53

Problem is that the fields that I wanted to use for faceting are simply not "facetable". It is not that they are not visible solr document, thats ok because fields are not stored in the index.

What I learned so far, in order to be facetable, filed should not be tokenised and it needs to have docValues="true" in solr document schema. With these changes, faceting started to work as expected. Since the solr schema is built automatically by alfresco, there is a "facetable" marker for alfresco properties(fields). Once turned on, fileds that were previously indexed and tokenized, now become Indexed, DocValues, Omit Norms, Omit Term Frequencies & Positions. Problem solved.

Upvotes: 0

zqb
zqb

Reputation: 1

try "group",but must be single value

Upvotes: 0

Related Questions