d-_-b
d-_-b

Reputation: 23171

Solr json.facet terms type not working for multivalued string field

I have a multivalued field in Solr, and trying to return terms facet for this field is yielding no results.

<fieldType name="industries_text" 
    class="solr.TextField" positionIncrementGap="100" 
    multiValued="true">

<field name="industries" type="industries_text" 
    sortMissingLast="true" indexed="true" stored="true" 
    multiValued="true" uninvertible="false" 
    omitPositions="true" />
"json.facet": {
    industries: {
       type: "terms",
       field: "industries",
       missing: true,
    }
}

This returns:

"industries": {
  "missing": {
    "count": 0
  },
  "buckets": []
}

yet when I query for all documents, there are industries: ["industry1", "industry2"] returned, so they are indexed.

Upvotes: 0

Views: 321

Answers (1)

MatsLindh
MatsLindh

Reputation: 52802

You're explicitly telling Solr that you don't want the field to be uninverted. That's a requirement for being able to create facets.

Swap uninvertible="false" to uninvertible="true" or leave it out to let it be the default value (true).

You want to set uninvertible="false" if the field supports docValues and they're enabled. TextFields does not support docValues, so if you plan to use it for any operation that requires an uninverted structure - such as Faceting - it will have to be uninvertible.

Upvotes: 2

Related Questions