0

我正在尝试使概念验证 Java 代码正常工作。我要做的第一件事是在我的 HD 上索引一些 txt 文档。但是,在尝试创建 Node.js 时遇到异常之前,我什至没有走那么远。

以下代码均产生以下异常:

代码

Node node = nodeBuilder().node();
Client client = node.client();

我的主要问题是

我在哪里可以获得似乎缺少的 BoundaryScanner 类?我将在异常下方提供我的 maven pom.xml 。lucene-fast-vector-highlighter 包似乎是最新版本3.0.3

非常感谢任何帮助。

例外

    07-Jun-2012 12:44:00 org.elasticsearch.node
INFO: [Allatou] {0.19.4}[2648]: initializing ...
07-Jun-2012 12:44:00 org.elasticsearch.plugins
INFO: [Allatou] loaded [], sites []
Exception in thread "main" org.elasticsearch.common.collect.ComputationException: java.lang.NoClassDefFoundError: org/apache/lucene/search/vectorhighlight/BoundaryScanner
    at org.elasticsearch.common.collect.ComputingConcurrentHashMap$ComputingMapAdapter.get(ComputingConcurrentHashMap.java:400)
    at org.elasticsearch.common.inject.internal.FailableCache.get(FailableCache.java:49)
    at org.elasticsearch.common.inject.ConstructorInjectorStore.get(ConstructorInjectorStore.java:50)
    at org.elasticsearch.common.inject.ConstructorBindingImpl.initialize(ConstructorBindingImpl.java:50)
    at org.elasticsearch.common.inject.InjectorImpl.initializeBinding(InjectorImpl.java:370)
    at org.elasticsearch.common.inject.BindingProcessor$1$1.run(BindingProcessor.java:148)
    at org.elasticsearch.common.inject.BindingProcessor.initializeBindings(BindingProcessor.java:204)
    at org.elasticsearch.common.inject.InjectorBuilder.initializeStatically(InjectorBuilder.java:119)
    at org.elasticsearch.common.inject.InjectorBuilder.build(InjectorBuilder.java:102)
    at org.elasticsearch.common.inject.Guice.createInjector(Guice.java:93)
    at org.elasticsearch.common.inject.Guice.createInjector(Guice.java:70)
    at org.elasticsearch.common.inject.ModulesBuilder.createInjector(ModulesBuilder.java:59)
    at org.elasticsearch.node.internal.InternalNode.<init>(InternalNode.java:149)
    at org.elasticsearch.node.NodeBuilder.build(NodeBuilder.java:159)
    at org.elasticsearch.node.NodeBuilder.node(NodeBuilder.java:166)
    at ie.openmobile.elasticsearch.Main.main(Main.java:49)
Caused by: java.lang.NoClassDefFoundError: org/apache/lucene/search/vectorhighlight/BoundaryScanner
    at java.lang.Class.getDeclaredConstructors0(Native Method)
    at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
    at java.lang.Class.getDeclaredConstructors(Unknown Source)
    at org.elasticsearch.common.inject.spi.InjectionPoint.forConstructorOf(InjectionPoint.java:177)
    at org.elasticsearch.common.inject.ConstructorInjectorStore.createConstructor(ConstructorInjectorStore.java:59)
    at org.elasticsearch.common.inject.ConstructorInjectorStore.access$000(ConstructorInjectorStore.java:29)
    at org.elasticsearch.common.inject.ConstructorInjectorStore$1.create(ConstructorInjectorStore.java:37)
    at org.elasticsearch.common.inject.ConstructorInjectorStore$1.create(ConstructorInjectorStore.java:33)
    at org.elasticsearch.common.inject.internal.FailableCache$1.apply(FailableCache.java:38)
    at org.elasticsearch.common.collect.ComputingConcurrentHashMap$ComputingValueReference.compute(ComputingConcurrentHashMap.java:358)
    at org.elasticsearch.common.collect.ComputingConcurrentHashMap$ComputingSegment.compute(ComputingConcurrentHashMap.java:184)
    at org.elasticsearch.common.collect.ComputingConcurrentHashMap$ComputingSegment.getOrCompute(ComputingConcurrentHashMap.java:153)
    at org.elasticsearch.common.collect.ComputingConcurrentHashMap.getOrCompute(ComputingConcurrentHashMap.java:69)
    at org.elasticsearch.common.collect.ComputingConcurrentHashMap$ComputingMapAdapter.get(ComputingConcurrentHashMap.java:396)
    ... 15 more
Caused by: java.lang.ClassNotFoundException: org.apache.lucene.search.vectorhighlight.BoundaryScanner
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 29 more

pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
      <modelVersion>4.0.0</modelVersion>

      <groupId>com.examplegroup</groupId>
      <artifactId>artifacename</artifactId>
      <version>1.0-SNAPSHOT</version>
      <packaging>jar</packaging>

      <name>elasticsearch</name>
      <url>http://maven.apache.org</url>


      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.12</version>
            <configuration>
              <systemPropertyVariables>
                <user.region>uk</user.region>
              </systemPropertyVariables>
            </configuration>
          </plugin>
        </plugins>
      </build>


      <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
      </properties>

         <repositories> 


         <repository> 
         <!-- elasticsearch hosted here -->
           <id>sonatype-releases</id> 
           <name>Sonatype Releases Repository</name> 
           <url>http://oss.sonatype.org/content/repositories/releases/</url> 
         </repository> 

       </repositories> 


      <dependencies>
        <dependency>
          <groupId>junit</groupId>
          <artifactId>junit</artifactId>
          <version>3.8.1</version>
          <scope>test</scope>
        </dependency>

        <dependency>
        <!-- jsoup HTML parser library @ http://jsoup.org/ -->
            <groupId>org.jsoup</groupId>
            <artifactId>jsoup</artifactId>
            <version>1.6.3</version>
        </dependency>

          <dependency>
            <groupId>org.apache.lucene</groupId>
            <artifactId>lucene-core</artifactId>
            <version>3.6.0</version>
          </dependency>           

          <dependency>                  
            <groupId>org.apache.lucene</groupId>
            <artifactId>lucene-analyzers</artifactId>   
            <version>3.6.0</version>                            
          </dependency>                                               

          <dependency>                                                      
            <groupId>org.apache.lucene</groupId>                                    
            <artifactId>lucene-snowball</artifactId>                                          
            <version>3.0.3</version>                                                                    
          </dependency>                                                                                         

          <dependency>
            <groupId>org.apache.lucene</groupId>
            <artifactId>lucene-fast-vector-highlighter</artifactId>
            <version>3.0.3</version>
          </dependency>

          <dependency>
            <groupId>org.apache.lucene</groupId>
            <artifactId>lucene-highlighter</artifactId>
            <version>2.4.0</version>
          </dependency>

          <dependency>
            <groupId>org.apache.lucene</groupId>
            <artifactId>lucene-queries</artifactId>
            <version>2.4.0</version>
          </dependency>


          <dependency>
            <groupId>org.elasticsearch</groupId>
            <artifactId>elasticsearch</artifactId>
            <version>0.19.4</version>
          </dependency>
      </dependencies>



    </project>
4

1 回答 1

3

在同一个项目中混合不同版本的 Lucene 组件并不是一个好主意。您应该对所有内容都使用 3.6.0。最近的版本有一些变化,所以你需要替换/删除一些工件。例如,Snowball 分析器现在位于 lucene-analyzers 中,因此您不需要 lucene-snowball 工件,而 lucene-fast-vector-highlighter 现在位于 lucene-highlighter 中:

      <dependency>
        <groupId>org.apache.lucene</groupId>
        <artifactId>lucene-core</artifactId>
        <version>3.6.0</version>
      </dependency>           

      <dependency>                  
        <groupId>org.apache.lucene</groupId>
        <artifactId>lucene-analyzers</artifactId>   
        <version>3.6.0</version>                            
      </dependency>                                               

      <dependency>
        <groupId>org.apache.lucene</groupId>
        <artifactId>lucene-highlighter</artifactId>
        <version>3.6.0</version>
      </dependency>

      <dependency>
        <groupId>org.apache.lucene</groupId>
        <artifactId>lucene-queries</artifactId>
        <version>3.6.0</version>
      </dependency>
于 2012-06-07T13:17:12.870 回答