【问题标题】:Implement dictionary using apache solr使用 apache solr 实现字典
【发布时间】:2016-02-18 16:01:17
【问题描述】:

我必须使用 apache solr 4.8 实现一个字典,以便它可以在网站上用于单词定义。我已经为它定义了一个简单的 solr 模式。其主要领域是

<field name="id" type="string" stored="true" indexed="true" required="true"/>
<field name="title" type="text_general" stored="true" indexed="true"/>
<field name="content" type="text_general" stored="true" indexed="false"/>
<field name="url" type="url" stored="true" indexed="true" />

搜索字段仅是标题

它是如何解决我的问题的,但它有一个问题。字典里也有一些谚语。字典里也有一句谚语wealky and wise。假设我输入 wealthy ,我希望 solr 应该给出准确单词的结果,但实际上它也显示了谚语定义的结果。

如何解决?我应该更改架构还是应用一些过滤器?

注意:solr 字典的实际实现不是英语而是本地语言。但我面临着与上面解释的类似的问题。

【问题讨论】:

  • 你是如何运行搜索的?您是自己生成搜索字符串还是使用 API 调用?了解 Solr 正在处理什么搜索字符串会很有帮助。此外,您可能需要更重地增加标题字段的权重。
  • 它是我用来调用 solr 以获取结果的 API

标签: python dictionary solr schema


【解决方案1】:

你必须使用keywordTokenizerFactory定义一个新的字段类型。

Guide about tokenizer can be found fromhere

更改您的架构,如下所示。 在 schema.xml 文件中

   <fieldType name="exactstring" class="solr.TextField" sortMissingLast="true" omitNorms="true">
    <analyzer type="query">
       <tokenizer class="solr.KeywordTokenizerFactory"/>
    </analyzer>
  </fieldType>
..........
..........
<field name="title" type="exactstring" indexed="true" stored="true" />

【讨论】:

    猜你喜欢
    • 2023-03-12
    • 2012-07-27
    • 1970-01-01
    • 1970-01-01
    • 2013-03-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-24
    相关资源
    最近更新 更多