【问题标题】:disable lowercase of facet fields in solr在 solr 中禁用 facet 字段的小写
【发布时间】:2012-01-16 15:44:13
【问题描述】:

我正在使用 solr 3.5 并添加了一个自定义字段,该字段通过在 schema.xml 中定义以下内容将类别添加到文档中。

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

现在我正在实现一个 Search-Web-Client,它应该显示该类别字段索引的所有值。我通过以下查询做到了:

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

结果如下:

<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 显示所有类别的名称,但它们是小写的,但以大写字母存储在索引中。

<response>
 <result>
  <doc>
   ...
   <str name="category">Category1</str>
   ...
  </doc>
 </result>
</response>
  • 解决方案 a:是否可以强制 facet-values 名称区分大小写?
  • 解决方案 b:是否有另一个查询可以提供存储在索引中的每个类别值?

【问题讨论】:

  • 您能否在schema.xml 中发布您的字符串字段类型的定义?这不是默认的,对吧?
  • 感谢您的帮助,这是默认定义。但我需要重新索引我的网站。

标签: solr full-text-search faceted-search


【解决方案1】:

我怀疑您正在使用LowerCaseFilterFactory 作为您的string 类型字段。在这种情况下,索引值为category1,但存储的值仍然是您提交的原始值Category1

您只需从schema.xml 中的string fieldType 定义中删除LowerCaseFilterFactory 即可获得所需的方面行为。

实际上,对于带有简单 fieldType 的 facet 使用特定的 copyField 是很常见的,没有TokenizerFilter 等。

【讨论】:

  • 感谢您的回答。我将类型从 text_general (具有 LowerCaseFilterFactory)更改为字符串。字符串没有这样的过滤器。我忘记删除索引并重新索引我的网页。之后一切正常。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多