How to avoid splitting field values ​​in facet search in solr

When searching on faces, in the search element, the doc element has a field with values ​​in the form of a string (more than words), but in the facet, each value has the form of a string with one word. Below is the search result for sample solr,

<result> <doc> <str name="fieldA">abc1 efg1 ijk1</str> <str name="fieldA">abc2 efg2 ijk2</str> <str name="fieldA">abc3 efg3 ijk3</str> <arr name="fieldD"> <str>abc1 efg1 ijk1</str> <str>abc2 efg2 ijk2</str> <str>abc3 efg3 ijk3</str> </arr> </doc> </result> <lst name="facet_counts"> <lst name="facet_queries"> <int name="fieldB:ab">some_number</int> </lst> <lst name="facet_fields"> <lst name="fieldA"> <int name="abc1">1</int> I want <int name="abc1 efg1 ijk1">1</int> <int name="efg1">1</int> <int name="ijk1">1</int> </lst> </lst> </lst> 

Schema.xml has fields - fieldA, fieldB, fieldC and fieldD, as shown below

  <field name="fieldA" type="text_general" stored="true" indexed="true"/> <field name="fieldB" type="text_general" stored="true" indexed="true"/> <field name="fieldC" type="text_general" stored="true" indexed="true"/> <field name="fieldD" type="text_general" stored="true" indexed="true"/> 

and

  <copyField source="fieldA" dest="fieldD"/> <copyField source="fieldB" dest="fieldD"/> <copyField source="fieldC" dest="fieldD"/> 

I want the facet values ​​of a string of multiple words to be exactly the same as the string of multiple words in field values. Please suggest.

+4
source share
1 answer

You need to change the field type="text_general" from type="text_general" to type="string" to find the facet.

If you cannot do this for this field, you can create a new row field (this could be a copy field), and then apply the facet to this.

+11
source

Source: https://habr.com/ru/post/1501476/


All Articles