6

I'm using solr 3.5 and added a custom field, which adds a category to a document by defining the following in schema.xml.

<field name="category" type="string" indexed="true" stored="true"/>

Now I'm implementing a Search-Web-Client, which should display all values of the index of that category field. I did that with the following query:

facet=true&facet.field=category&q=*

The results look like:

<response>
 <lst name="responseHeader">
  <int name="status">0</int>
  <int name="QTime">45</int>
  <lst name="params">
   <str name="facet.field">category</str>
   <str name="q">*</str>
   <str name="facet">true</str>
  </lst>
 </lst>
 <result name="response" numFound="0" start="0" maxScore="0.0"/>
  <lst name="facet_counts">
  <lst name="facet_queries"/>
  <lst name="facet_fields">
  <lst name="category">
   <int name="category1">0</int>
   <int name="category2">0</int>
   <int name="category3">0</int>
   <int name="category4">0</int>
   <int name="category5">0</int>
  </lst>
 </lst>
 <lst name="facet_dates"/>
  <lst name="facet_ranges"/>
  </lst>
</response>

My Web-Client displays all names of categories, but they are written in lowercase, but are stored in the index with capital letter.

<response>
 <result>
  <doc>
   ...
   <str name="category">Category1</str>
   ...
  </doc>
 </result>
</response>
  • Solution a: Is it possible to force the facet-values names to be case-sensitive?
  • Solution b: Is there another query which will give every value of category stored in the index?
javanna
  • 59,145
  • 14
  • 144
  • 125
jpee
  • 311
  • 2
  • 15
  • 1
    Can you please post the definition of your string fieldType in your `schema.xml`? It isn't the default one, right? – javanna Jan 16 '12 at 16:43
  • Thanks for your help, it is the default definition. But I needed to reindex my sites. – jpee Jan 17 '12 at 09:20

1 Answers1

13

I suspect you're using a LowerCaseFilterFactory for your field of type string. In that case, the indexed values is category1 but the stored value is still the original you submitted, Category1.

You should just remove the LowerCaseFilterFactory from the string fieldType definition in your schema.xml to have the desired facet behaviour.

In fact, it's common to use specific copyField for facet with simple fieldType, without Tokenizer, Filter etc.

javanna
  • 59,145
  • 14
  • 144
  • 125
  • Thanks for your answer. I changed the type from text_general (which has a LowerCaseFilterFactory) to string. String doesn't have such a filter. I forgot to delete the index and reindex my webpages. After that everything worked fine. – jpee Jan 17 '12 at 09:17