Question

I have dynamicField as 'pa_mydynamicfieldname' in Solr 4.0

I have store value in this field as :

I have indexed my data by Encoding using System.Web.HttpUtility.UrlEncode(pa_mydynamicfieldname) such as : 2.2+GHz+Intel+Pentium+Dual-Core+E2200

When i apply facet query to get result then output is as :

<lst name="facet_fields">
<lst name="pa_mydynamicfieldname">
    <int name="2.2">1</int>
    <int name="2.5">1</int>
    <int name="core">1</int>
    <int name="dual">1</int>
    <int name="e2200">1</int>
    <int name="ghz">1</int>
    <int name="intel">1</int>
    <int name="pentium">1</int>
</lst>

Instead of this I want output as :

<lst name="facet_fields">
<lst name="pa_mydynamicfieldname">
    <int name="2.2+GHz+Intel+Pentium+Dual-Core+E2200">1</int>
</lst>

how can do this in Solr while applying facet query ?

Updated on 15-May-13

From Schema, text field is defined as:

<fieldType name="text" class="solr.TextField" positionIncrementGap="100">

And dynamic field is defined as:

<dynamicField name="pa_*" type="text" indexed="true" stored="true" multiValued="true" required="false" />

We need it as multi-valued field, because a document may have multiple value defined for each product.

Please Help me.

Thanks

Was it helpful?

Solution

In order to accomplish the behavior that you are desiring, you will need to change the fieldType for the dynamic field in your schema.xml. Currently, your pa_mydyanmicfieldname is probably defined as a type="text_general" and with multivalued="true". So your field value is being split into tokens and these tokens are then being stored as multiple values. This is producing the behavior you show with multiple words/tokens being returned as facet values.

Since you want to store the original value as you submit it, please change your fieldType to just a plain old string and not multivalued:

 <dynamicField name="*_mydynamicfeldname" type="string" 
           indexed="true" stored="true"/>

Or you can alternately take advantage of the predefined string based dynamic field defined in the example schema.xml:

 <dynamicField name="*_s"  type="string"  indexed="true"  stored="true" />

You will need to reindex your data after making this change to your schema.xml for new field types to be stored properly and reflected in the search results.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top