简体   繁体   中英

How to get collapsible results on solr text fields using solr facet query?

I am generating a stats report from solr using facet queries. When generating exception report , we grouped the exception using its class_name field in solr.

schema.xml

<field name="class_name" type="text" indexed="true" stored="false" compressed="false"/>

Solr Query

http://ultrasound.zmedia.com/solr/goo/select/?q=exception&version=2.2&start=0&rows=0&indent=on&facet=true&facet.field=class_name

Solr Query Results

    <response>
<lst name="responseHeader">
<int name="status">0</int>
<int name="QTime">59</int>
</lst>
<result name="response" numFound="1068" start="0"/>
<lst name="facet_counts">
<lst name="facet_queries"/>
<lst name="facet_fields">
<lst name="class_name">
<int name="com">1068</int>
<int name="zmedia">1057</int>
<int name="pool">120</int>
<int name="processor">130</int>
<int name="server">53</int>
<int name="tldresult">43</int>
<int name="tomcat">20</int>
<int name="user">19</int>
<int name="util">19</int>
</lst>
</lst>
<lst name="facet_dates"/>
<lst name="facet_ranges"/>
</lst>
</response>

Expected Result

    <response>
<lst name="responseHeader">
<int name="status">0</int>
<int name="QTime">59</int>
</lst>
<result name="response" numFound="1068" start="0"/>
<lst name="facet_counts">
<lst name="facet_queries"/>
<lst name="facet_fields">
<lst name="class_name">
<int name="com.zmedia.tomcat">20</int>
<int name="com.zmedia.user.util">19</int
</lst>
</lst>
<lst name="facet_dates"/>
<lst name="facet_ranges"/>
</lst>
</response>

How can i do this?. I cannot change the datatype , because it's running in production setup.

As the field is text and tokenized, the facets returned would be individual words instead of the Complete string.
There is no other option then to change the datatype or maintain a different field with string datatype and this would need change in Configuration and reindexing.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM