Solr CapitalizationFilterFactory 不工作

发布于 2024-12-05 23:11:39 字数 1668 浏览 0 评论 0原文

当谈到 solr 时,我是一个完全的菜鸟,这是我的第一个配置,我在正确过滤 solr 数据时遇到问题。我们使用的是 solr 4.0,2011 年 9 月 21 日的快照。我想要的是在各个字段中将每个单词的第一个字母大写。我们索引的数据将包含“name”=“STAR WARS”之类的数据。我想要的是,当我查询数据时,名称应该返回为“星球大战”,但返回为“星球大战”

这是我的设置

<fieldType name="text_capital" class="solr.TextField" positionIncrementGap="100">
  <analyzer type="index">
    <tokenizer class="solr.WhitespaceTokenizerFactory"/>                
    <filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" catenateWords="1" catenateNumbers="1" catenateAll="0" splitOnCaseChange="1"/>
    <filter class="solr.LowerCaseFilterFactory"/>
    <filter class="solr.CapitalizationFilterFactory" onlyFirstWord="false" okPrefix="CVS"/>         
    <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
  </analyzer>
  <analyzer type="query">                      
    <tokenizer class="solr.WhitespaceTokenizerFactory"/>
    <filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" catenateWords="0" catenateNumbers="0" catenateAll="0" splitOnCaseChange="1"/>
    <filter class="solr.LowerCaseFilterFactory"/>
    <filter class="solr.CapitalizationFilterFactory" onlyFirstWord="false" okPrefix="CVS"/>                
    <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
  </analyzer>
</fieldType>

这是字段映射

<field name="name" type="text_capital" indexed="true" stored="true" />

现在,当我查看分析器时,一切看起来都很好查询和索引都正确命中分词器和所有过滤器,但是当我运行查询结果时,名称全部大写。我觉得我在这里遗漏了一些明显的东西。

谢谢,

-扎克

I am a complete noob when it comes to solr, this is my first configuration and I am having issues getting solr data to be filtered properly. We are using solr 4.0, the 09-21-2011 snapshot. What I want is to capitalize the first letter of each word in various fields. The data we index will have data like 'name' = 'STAR WARS'. What i want is when I query the data that the name should come back as 'Star Wars' but is comes back as 'STAR WARS'

Here is my setup

<fieldType name="text_capital" class="solr.TextField" positionIncrementGap="100">
  <analyzer type="index">
    <tokenizer class="solr.WhitespaceTokenizerFactory"/>                
    <filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" catenateWords="1" catenateNumbers="1" catenateAll="0" splitOnCaseChange="1"/>
    <filter class="solr.LowerCaseFilterFactory"/>
    <filter class="solr.CapitalizationFilterFactory" onlyFirstWord="false" okPrefix="CVS"/>         
    <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
  </analyzer>
  <analyzer type="query">                      
    <tokenizer class="solr.WhitespaceTokenizerFactory"/>
    <filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" catenateWords="0" catenateNumbers="0" catenateAll="0" splitOnCaseChange="1"/>
    <filter class="solr.LowerCaseFilterFactory"/>
    <filter class="solr.CapitalizationFilterFactory" onlyFirstWord="false" okPrefix="CVS"/>                
    <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
  </analyzer>
</fieldType>

And here is the field mapping

<field name="name" type="text_capital" indexed="true" stored="true" />

Now when i look at the analyzer everything looks fine for both query and index it hits the tokenizer and all the filters properly, but when i run a query results come back with the name as all caps. I feel like i am missing something obvious here.

Thanks,

-zach

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

掩耳倾听 2024-12-12 23:11:39

您所说的“返回”值是存储的值,它始终是您在索引时提供给 Solr 的逐字值。分词器、过滤器等会影响搜索(以及查询词)时使用的索引值。您可以将获得的存储值转换回您想要的形式。

The value you refer as "coming back" is the stored value which is always the verbatim value you fed to Solr when indexing. Tokenizers, filters, etc, affect the indexed value which is used when searching (and the query terms). It's up to you to transform the stored value you get back into the form you want.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文