【问题标题】:Solr Multivalued Field Detecting LanguageSolr 多值场检测语言
【发布时间】:2017-10-23 08:44:09
【问题描述】:

“我想问一下,简化一个示例。我在模式中有 2 个字段。

<fieldType name="text_field" class="solr.TextField" positionIncrementGap="100" />
<field name="title" type="text_field" indexed="true" stored="true" multiValued="true"/>
<field name="content" type="text_field" indexed="true" stored="true" multiValued="true"/>

titlecontent 字段返回 2 个语言值。 1. 土耳其语,2. 英语

title:[
    "Orta Doğu Teknik Üniversitesi",
    "Middle East Technical University"
]

content:[
    "Örnek içerik",
    "Example content"
]

问题

当我索引它时,我希望将 titlecontent 字段拆分为 title_trtitle_encontent_trcontent_en

我知道我将使用LanguageDetection 来检测和更新语言。但我不知道如何提出我的要求。

我使用的是 Solr 4.9.0 版本。


<field name="title_en" type="text_field" indexed="true" stored="true" multiValued="true" />
<field name="content_en" type="text_field" indexed="true" stored="true" multiValued="true" />
<field name="title_tr" type="text_field" indexed="true" stored="true" multiValued="true"/>
<field name="content_tr" type="text_field" indexed="true" stored="true" multiValued="true"/>

<copyField source="title" dest="title_tr"/>
<copyField source="content" dest="content_tr"/>
<copyField source="title" dest="title_en"/>
<copyField source="content" dest="content_en"/>

我想要结果:

title_tr:[
    "Orta Doğu Teknik Üniversitesi"
]

title_en:[
    "Middle East Technical University"
]

content_tr:[
    "Örnek içerik"
]

content_en:[
    "Example content"
]

我该怎么做?

【问题讨论】:

  • 你在使用 DataImportHandler 吗?
  • @Oyeme,不,我使用的是 solr4j。
  • @Oyeme,我有索引数据之前的最终状态:title:[ "Orta Doğu Teknik Üniversitesi", "Middle East Technical University" ] content:[ "Örnek içerik", "Example content" ]
  • 你为什么不为此使用更新链处理器?
  • 我没有尝试解决方案。因为我不得不处理另一个项目。

标签: indexing solr


【解决方案1】:

如果你想在 Solr 端解决它,我建议你开发自己的 UpdateRequestProcessor[1] 。

你可以在那里实现你的逻辑:

1) 扫描多字段中的每个值

2) 识别语言(您可以查看此 UpdateRequestprocessor[2] 中的方法

3) 使用要索引的值创建一个字段 text_

[1]https://lucene.apache.org/solr/guide/6_6/update-request-processors.html

[2]https://lucene.apache.org/solr/6_6_0//solr-langid/org/apache/solr/update/processor/LangDetectLanguageIdentifierUpdateProcessorFactory.html

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-30
    • 2017-02-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多