Best Practices: Display Facets which are not the real field values

In most UIs, the facet display shows the text string in the matching document field. For example, in LucidWorks Search, the facets drill-down for document type shows the actual MIME-type strings instead of "PDF", "MSWord 2003", etc.

This standard technique sometimes does not work. The displayed strings may not work as search query strings. Either they have punctuation in them, or they include world language characters which do not play well with URL syntax. This can be solved by using this search syntax to use the facet as a filter query:

fq={!term f=field_name}field_value

Another problem is that facet values are often context-dependent.  For example, you may show 'Towels' in both kitchen and bathroom sections of an e-commerce site, but you want to filter for 'kitchen_towels' v.s. 'bathroom_towels'.

There is a trick for this: don't display the Solr field value! Instead, create a field value which includes both the values for the data model, and also a displayable string. You might encode the display part of the string in some format like base64 or UTF-8 bytes. Now, in the UI, you select the display part of the full facet value, display that, and send the full key back in the Solr query.

Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.
Powered by Zendesk