Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to avoid splitting of field values in faceted search in solr

Tags:

solr

While facet-based searching, in the search result doc element has field with values in the form of string(of more than words) but in the facet, every value is in the form of string with single word. Following is the sample solr search result,

<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 like following

  <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 string of multiple words just like in the string of multiple words in the field values. Please suggest.

like image 442
abhijeet Avatar asked Sep 10 '13 13:09

abhijeet


1 Answers

You have to change the type of your field from type="text_general" into type="string" for the facet search.

If you can't do it for that field you can create a new string field (it could be a copyfield) and then apply the facet on that one.

like image 53
Maurizio In denmark Avatar answered Oct 17 '22 15:10

Maurizio In denmark