arraysstringsolrfacetfaceted-search

Solr Facet split string in multiple terms. How to include whitespace?


I'm using Solr 8.2.0, I'm indexing data in arrays to use in facets. This is an example of the facet field

"authors_facet":["John Smith", "Hillary Clinton"]

In the json response I have these facets:

authors_facet":[
        "john",531,
        "smith",531,
        "hillary",531,
        "clinton",531
]

I want instead to have facets like this:

authors_facet":[
        "john smith",531,
        "hillary clinton",531
]

How can I do this?


Solution

  • You need to make sure that you use a string field for facets. From the look of it your authors_facet field is a tokenized field (like a text field) and hence you see the tokens as facets.

    See also https://github.com/hectorcorrea/solr-for-newbies/blob/master/tutorial.md#facets