【问题标题】:automatic language detect in solr 4.5.1 during indexing time在索引期间在 solr 4.5.1 中自动检测语言
【发布时间】:2014-07-12 10:09:53
【问题描述】:

我需要你的帮助。 我想在 solr 的索引时间内检测韩语和英语。

我的solr目录结构是

/opt/tmocat7/webapps/solr (solr webapp)
/usr/share/solr/collection1 (solr core)
/usr/share/solr/lib/langid (lib for langid)

首先,我将一些库(jsonic-1.2.7.jar,langdetect-1.1-20120112.jar,solr-langid-4.5.1.jar)复制到特定目录(/usr/share/solr/lib/langid ) - 我的 solr 位于

我的 solrconfig.xml 是

<lib dir="../lib/langid/" regex=".*\.jar" />

<requestHandler name="/update" class="solr.UpdateRequestHandler">    
    <lst name="defaults">   
    <str name="update.chain">dedupe</str> 
    <str name="update.chain">uuid</str>
    <str name="update.chain">langid</str>
    </lst>
</requestHandler>

<updateRequestProcessorChain name="langid">
    <processor class="org.apache.solr.update.processor.LangDetectLanguageIdentifierUpdateProcessorFactory">
        <bool name="langid">true</bool>
        <str name="langid.fl">title,content,comment</str>
        <str name="langid.langField">lang</str>
        <str name="langid.langsField">langs</str>
        <str name="langid.lcmap">ko:ko kor:ko en_GB:en en_US:en</str>
        <str name="langid.whitelist">ko,en</str>
        <bool name="langid.map">true</bool>
        <str name="langid.map.fl">title,content,comment</str>
        <bool name="langid.map.keepOrig">true</bool>
        <bool name="langid.map.individual">true</bool> 
        <str name="langid.fallback">ko</str>         
        <str name="langid.map.lcmap">ko:ko kor:ko en_GB:en en_US:en</str>
    </processor>
    <processor class="solr.LogUpdateProcessorFactory" />
    <processor class="solr.RunUpdateProcessorFactory" />
</updateRequestProcessorChain>

schema.xml 是

<field name="lang" type="string" indexed="true" stored="true" multiValued="false" />
<field name="langs" type="string" indexed="true" stored="true" multiValued="true" />
<field name="id" type="string" indexed="true" stored="true" required="true" multiValued="false" />
<field name="title" type="text_ko" indexed="true" stored="true" multiValued="true"/>
<field name="content" type="text_ko" indexed="true" stored="true" multiValued="true"/>
<field name="comment" type="text_ko" indexed="true" stored="true" multiValued="true" />
<field name="site" type="text_general" indexed="true" stored="true" multiValued="false"/>
<field name="page" type="text_general" indexed="true" stored="true" multiValued="false"/>
<field name="fileloc" type="text_general" indexed="true" stored="true" 
 multiValued="false"/> 
<field name="filename" type="text_general" indexed="true" stored="true"
 multiValued="false" />
<field name="storeddate" type="date" indexed="true" stored="true" multiValued="false"/>    

<!-- for english web data-->

<field name="title_en" type="text_en" indexed="true" stored="true" multiValued="true" />
<field name="content_en" type="text_en" indexed="true" stored="true" multiValued="true" />
<field name="comment_en" type="text_en" indexed="true" stored="true" multiValued="true" />

<field name="title_ko" type="text_ko" indexed="true" stored="true" multiValued="true"/>
<field name="content_ko" type="text_ko" indexed="true" stored="true" multiValued="true"/>
<field name="comment_ko" type="text_ko" indexed="true" stored="true" multiValued="true" />

<copyField source="title" dest="title_en"/>
<copyField source="content" dest="content_en"/>
<copyField source="comment" dest="comment_en"/>
<copyField source="title" dest="title_ko"/>
<copyField source="content" dest="content_ko"/>
<copyField source="comment" dest="comment_ko"/>

我阅读了一些书籍并搜索网络以获取有关在 solr 中检测语言的信息,但无法检测语言。 我的错是什么?

更多信息,添加我的post.sh和日志

这是 post.sh

#!/bin/sh
FILES=$*
URL=http://locahost:port/solr/collection1/update

for f in $FILES; do
  echo Posting file $f to $URL
  curl $URL --data-binary @$f -H 'Content-type:application/xml'
  echo
done

#send the commit command to make sure all the changes are flushed and visible
curl $URL --data-binary '<commit/>' -H 'Content-type:application/xml'

echo

索引期间的部分tomcat日志

70634079 [http-bio-7070-exec-38] TRACE org.apache.solr.handler.UpdateRequestHandler  – body
70634079 [http-bio-7070-exec-38] DEBUG org.apache.solr.update.processor.LogUpdateProcessor  – PRE_UPDATE add{,id=2f2323f4f7966e0d} {{params({params(),defaults(update.chain=dedupe&update.chain=uuid&update.chain=langid)}),defaults(wt=xml)}}
70634125 [http-bio-7070-exec-38] TRACE org.apache.solr.update.UpdateLog  – TLOG: added id 2f2323f4f7966e0d to tlog{file=/usr/share/solr/collection1/data/tlog/tlog.0000000000000000129 refcount=1} LogPtr(29407) map=614254179
70634125 [http-bio-7070-exec-38] DEBUG org.apache.solr.update.processor.LogUpdateProcessor  – PRE_UPDATE FINISH {{params({params(),defaults(update.chain=dedupe&update.chain=uuid&update.chain=langid)}),defaults(wt=xml)}}
70634126 [http-bio-7070-exec-38] INFO  org.apache.solr.update.processor.LogUpdateProcessor  – [collection1] webapp=/solr path=/update params={} {add=[2f2323f4f7966e0d (1473490520171872256)]} 0 68
70634146 [http-bio-7070-exec-33] TRACE org.apache.solr.handler.UpdateRequestHandler  – body
70634146 [http-bio-7070-exec-33] DEBUG org.apache.solr.update.processor.LogUpdateProcessor  – PRE_UPDATE add{,id=329ee20831e1a0c7} {{params({params(),defaults(update.chain=dedupe&update.chain=uuid&update.chain=langid)}),defaults(wt=xml)}}
70634148 [http-bio-7070-exec-33] TRACE org.apache.solr.update.UpdateLog  – TLOG: added id 329ee20831e1a0c7 to tlog{file=/usr/share/solr/collection1/data/tlog/tlog.0000000000000000129 refcount=1} LogPtr(46005) map=614254179
70634148 [http-bio-7070-exec-33] DEBUG org.apache.solr.update.processor.LogUpdateProcessor  – PRE_UPDATE FINISH {{params({params(),defaults(update.chain=dedupe&update.chain=uuid&update.chain=langid)}),defaults(wt=xml)}}
70634148 [http-bio-7070-exec-33] INFO  org.apache.solr.update.processor.LogUpdateProcessor  – [collection1] webapp=/solr path=/update params={} {add=[329ee20831e1a0c7 (1473490520241078272)]} 0 2

我找不到任何其他警告或错误。 我需要你的建议 谢谢大家

【问题讨论】:

  • 您没有说您面临的实际下一步问题是什么。但是使用上面的配置,您可能会遇到异常,因为上面的 lib 指令将 regex 拼写为 regx。所以你可能没有得到你的图书馆。
  • 谢谢你,Alexandre,拼写错误是我的错。修复后还是有问题。
  • 我编辑我的问题。我没有错误、警告和 LangDetectLanguageIdentifierUpdateProcessorFactory 日志。如果检测器运行良好,我可以查看 LangDetectLanguageIdentifierUpdateProcessorFactory 日志吗?

标签: solr language-detection


【解决方案1】:

我认为您使用 /update/extract 而不是 /update

在 Solr 5.3.1 中,当我与 /update/extract 一起使用时,它可以正常工作。

这是完整的配置:

<requestHandler name="/update/extract" 
              startup="lazy"
              class="solr.extraction.ExtractingRequestHandler" >
<lst name="defaults">
  <str name="lowernames">true</str>
  <str name="uprefix">ignored_</str>

  <!-- capture link hrefs but ignore div attributes -->
  <str name="captureAttr">true</str>
  <str name="fmap.a">links</str>
  <str name="fmap.div">ignored_</str>

  <str name="update.chain">langid</str>
</lst>

【讨论】:

  • 能否请您 edit 解释一下为什么这段代码回答了这个问题?
【解决方案2】:

感谢您提出的问题和出色的答案,他们帮助我正确配置了我的系统。我不知道我是如何设法将 JAR 文件 solr-langdetect.*.*.*.jar 放入我的 lib 目录中的,但是每次启动 solr 时都会显示以下错误:

org.apache.solr.common.SolrException: com.cybozu.labs.langdetect.DetectorFactory.loadProfile(Ljava/util/List;)V

删除该 JAR 文件后一切正常。但是,问题中提到的其他三个 JAR 文件(jsonic-*.*.*.jarlangdetect-*.*.jarsolr-langid-*.*.*.jar)是必需的。

【讨论】:

    猜你喜欢
    • 2020-07-25
    • 1970-01-01
    • 2016-11-17
    • 1970-01-01
    • 1970-01-01
    • 2012-08-27
    • 1970-01-01
    • 1970-01-01
    • 2018-07-13
    相关资源
    最近更新 更多