无法在Windows

时间:2018-03-22 16:37:42

标签: solr lucene nlp solrcloud opennlp

我正在尝试将补丁LUCENE-2899.patch应用于Solr。

我做到了:

  1. 来自官方回购的克隆solr(我在主分公司)
  2. 下载并安装了ant和GNU补丁,我在这里http://gnuwin32.sourceforge.net/packages/patch.htm
  3. 将Ant和GNU补丁放到PATH env var。
  4. 我得到了这个......
  5. ```

    D:\utils\solr_master\lucene-solr>patch -p1 -i LUCENE-2899.patch --dry-run
    patching file dev-tools/idea/.idea/ant.xml
    Assertion failed: hunk, file ../patch-2.5.9-src/patch.c, line 354
    
    This application has requested the Runtime to terminate it in an unusual way.
    Please contact the application's support team for more information.
    

    ```

    更新1

    我正在尝试编译,但构建失败。

    D:\utils\solr_master\lucene-solr>ant compile
    Buildfile: D:\utils\solr_master\lucene-solr\build.xml
    
    BUILD FAILED
    D:\utils\solr_master\lucene-solr\build.xml:21: The following error occurred while executing this line:
    D:\utils\solr_master\lucene-solr\lucene\common-build.xml:623: java.lang.NullPointerException
            at java.util.Arrays.stream(Arrays.java:5004)
            at java.util.stream.Stream.of(Stream.java:1000)
            at java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:267)
            at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
            at java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948)
            at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
            at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
            at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:545)
            at java.util.stream.AbstractPipeline.evaluateToArrayNode(AbstractPipeline.java:260)
            at java.util.stream.ReferencePipeline.toArray(ReferencePipeline.java:438)
            at org.apache.tools.ant.util.ChainedMapper.lambda$mapFileName$1(ChainedMapper.java:36)
            at java.util.stream.ReduceOps$1ReducingSink.accept(ReduceOps.java:80)
            at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382)
            at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
            at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
            at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
            at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
            at java.util.stream.ReferencePipeline.reduce(ReferencePipeline.java:484)
            at org.apache.tools.ant.util.ChainedMapper.mapFileName(ChainedMapper.java:35)
            at org.apache.tools.ant.util.CompositeMapper.lambda$mapFileName$0(CompositeMapper.java:32)
            at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
            at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175)
            at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382)
            at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
            at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
            at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:545)
            at java.util.stream.AbstractPipeline.evaluateToArrayNode(AbstractPipeline.java:260)
            at java.util.stream.ReferencePipeline.toArray(ReferencePipeline.java:438)
            at org.apache.tools.ant.util.CompositeMapper.mapFileName(CompositeMapper.java:33)
            at org.apache.tools.ant.taskdefs.PathConvert.execute(PathConvert.java:363)
            at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
            at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
            at java.lang.reflect.Method.invoke(Method.java:498)
            at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
            at org.apache.tools.ant.Task.perform(Task.java:346)
            at org.apache.tools.ant.Target.execute(Target.java:448)
            at org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:172)
            at org.apache.tools.ant.taskdefs.ImportTask.importResource(ImportTask.java:221)
            at org.apache.tools.ant.taskdefs.ImportTask.execute(ImportTask.java:165)
            at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
            at java.lang.reflect.Method.invoke(Method.java:498)
            at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
            at org.apache.tools.ant.Task.perform(Task.java:346)
            at org.apache.tools.ant.Target.execute(Target.java:448)
            at org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:183)
            at org.apache.tools.ant.ProjectHelper.configureProject(ProjectHelper.java:93)
            at org.apache.tools.ant.Main.runBuild(Main.java:824)
            at org.apache.tools.ant.Main.startAnt(Main.java:228)
            at org.apache.tools.ant.launch.Launcher.run(Launcher.java:283)
            at org.apache.tools.ant.launch.Launcher.main(Launcher.java:101)
    
    Total time: 0 seconds
    

    更新2

    我从

    下载了Solr

    https://builds.apache.org/job/Solr-Artifacts-7.3/lastSuccessfulBuild/artifact/solr/package/ https://builds.apache.org/job/Solr-Artifacts-master/lastSuccessfulBuild/artifact/solr/package/

    7.3 版本和 8.0(主版)版本都没有在 contrib dir中看不到 opennlp dir / em>的。我在哪里可以找到它?

    更新3

    我已经从我在这里下载的主分支中运行了版本https://builds.apache.org/job/Solr-Artifacts-master/lastSuccessfulBuild/artifact/solr/package/,我试图在这篇文章中像绅士一样运行OpenNLP:

    Exception while integrating openNLP with Solr

    但我和他有同样的错误。

      

    numberplate_shard1_replica_n1:
      org.apache.solr.common.SolrException:org.apache.solr.common.SolrException:>无法为核心numberplate_shard1_replica_n1加载conf:无法加载架构> managed-schema:[schema.xml]的插件初始化失败fieldType>“text_opennlp_nvf”:[schema.xml] analyzer / tokenizer的插件初始化失败:>实例化类的错误:'org.apache.lucene.analysis.opennlp.OpenNLPTokenizerFactory'

    如果将LUCENE-2899补丁合并到主控器中,为什么会出现此错误?

    更新5

    我重启了solr,错误消失了。但...

    我试图添加字段(到托管架构)以形成示例(https://wiki.apache.org/solr/OpenNLP):

    <fieldType name="text_opennlp" class="solr.TextField">
          <analyzer>
            <tokenizer class="solr.OpenNLPTokenizerFactory"
              sentenceModel="opennlp/en-sent.bin"
              tokenizerModel="opennlp/en-token.bin"
            />
          </analyzer>
        </fieldType>
    
        <field name="content" type="text_opennlp" indexed="true" termOffsets="true" stored="true" termPayloads="true" termPositions="true" docValues="false" termVectors="true" multiValued="true" required="true"/>
    

    但是当我尝试在云模式下运行Solr时,我得到了这个:

    D:\utils\solr-7.3.0-7\solr-7.3.0-7\bin>solr -e cloud
    
    Welcome to the SolrCloud example!
    
    This interactive session will help you launch a SolrCloud cluster on your local workstation.
    To begin, how many Solr nodes would you like to run in your local cluster? (specify 1-4 nodes) [2]:
    1
    Ok, let's start up 1 Solr nodes for your example SolrCloud cluster.
    Please enter the port for node1 [8983]:
    
    Solr home directory D:\utils\solr-7.3.0-7\solr-7.3.0-7\example\cloud\node1\solr already exists.
    
    Starting up Solr on port 8983 using command:
    "D:\utils\solr-7.3.0-7\solr-7.3.0-7\bin\solr.cmd" start -cloud -p 8983 -s "D:\utils\solr-7.3.0-7\solr-7.3.0-7\example\cloud\node1\solr"
    
    Waiting up to 30 to see Solr running on port 8983
    Started Solr server on port 8983. Happy searching!
    INFO  - 2018-03-26 14:42:26.961; org.apache.solr.client.solrj.impl.ZkClientClusterStateProvider; Cluster at localhost:9983 ready
    
    Now let's create a new collection for indexing documents in your 1-node cluster.
    Please provide a name for your new collection: [gettingstarted]
    numberplate
    
    Collection 'numberplate' already exists!
    Do you want to re-use the existing collection or create a new one? Enter 1 to reuse, 2 to create new [1]:
    1
    
    Enabling auto soft-commits with maxTime 3 secs using the Config API
    
    POSTing request to Config API: http://localhost:8983/solr/numberplate/config
    {"set-property":{"updateHandler.autoSoftCommit.maxTime":"3000"}}
    
    ERROR: Error from server at http://localhost:8983/solr: Expected mime type application/octet-stream but got text/html. <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
    <title>Error 404 Not Found</title>
    </head>
    <body><h2>HTTP ERROR 404</h2>
    <p>Problem accessing /solr/numberplate/config. Reason:
    <pre>    Not Found</pre></p>
    </body>
    </html>
    
    
    
    
    SolrCloud example running, please visit: http://localhost:8983/solr
    
    
    D:\utils\solr-7.3.0-7\solr-7.3.0-7\bin>
    

    更新6

    我创建了新的集合,我得到了更精确的错误:

      

    test_collection_shard1_replica_n1:&gt; org.apache.solr.common.SolrException:org.apache.solr.common.SolrException:&gt;无法为核心test_collection_shard1_replica_n1加载conf:无法加载&gt; schema managed-schema:org.apache.solr.core.SolrResourceNotFoundException:&gt;无法在类路径或'/ configs / _default'中找到资源'opennlp / en-sent.bin',&gt; CWD = d:\ utils的\ solr的-7.3.0-7 \ solr的-7.3.0-7 \服务器   请查看您的日志以获取更多信息

    也许我需要复制一些OpenNLP模型http://opennlp.sourceforge.net/models-1.5/

    但我可以在哪里放这个型号?

    你能帮帮我吗?我做错了什么?

1 个答案:

答案 0 :(得分:1)

正如您在LUCENE-2899上看到的那样,补丁已经应用于8.0(主)以及7.3。

您可以在Solr-Artifacts-master for (currently) 8.0Solr-Artifacts-7.3 for 7.3找到预建的夜莺。

opennlp库捆绑在工件中:

solr-8.0.0-3304 find . -name '*nlp*'
[...]
./contrib/langid/lib/opennlp-tools-1.8.3.jar
./contrib/analysis-extras/lib/opennlp-maxent-3.0.3.jar
./contrib/analysis-extras/lib/opennlp-tools-1.8.3.jar
./contrib/analysis-extras/lucene-libs/lucene-analyzers-opennlp-8.0.0-3304.jar

然后你必须告诉Solr加载这些you can do through solrconfig.xml

的罐子
<lib dir="../../../contrib/analysis-extras/lib/" regex="opennlp-.*\.jar" />
<lib dir="../../../contrib/analysis-extras/lucene-libs/lucene-analyzers-opennlp-.*\.jar" regex=".*\.jar" />

确认在Solr的日志文件中按预期加载了罐子。