Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 需要显示给定索引的所有术语_Java_Search_Lucene_Full Text Search - Fatal编程技术网

Java 需要显示给定索引的所有术语

Java 需要显示给定索引的所有术语,java,search,lucene,full-text-search,Java,Search,Lucene,Full Text Search,我需要显示给定Lucene索引的所有术语 public void addDocuments(IndexWriter indexWriter) throws IOException { Document doc1 = new Document(); doc1.add(new TextField("title", "harrypotter", Field.Store.YES)); indexWriter.addDocument(doc1); Document

我需要显示给定Lucene索引的所有术语

    public void addDocuments(IndexWriter indexWriter) throws IOException {
    Document doc1 = new Document();
    doc1.add(new TextField("title", "harrypotter", Field.Store.YES));
    indexWriter.addDocument(doc1);

    Document doc2 = new Document();
    doc2.add(new TextField("title", "luceneinaction", Field.Store.YES));
    indexWriter.addDocument(doc2);

    Document doc3 = new Document();
    doc3.add(new TextField("title", "harrypotter", Field.Store.YES));
    indexWriter.addDocument(doc3);
}
我正在尝试:

    Fields fields = MultiFields.getFields(reader);
    Terms terms = fields.terms("title");
    TermsEnum iterator = terms.iterator(null);          
    BytesRef byteRef = null;
    while((byteRef = iterator.next()) != null) {
        System.out.println(byteRef.utf8ToString());
    }
然而,这给了我唯一的术语:

harrypotter
luceneinaction
是否有办法获得所有条款(以及副本)?或者术语总是唯一的

谢谢

PS:Lucene版本是4.0。

Lucene是一个,因此它存储了对以下术语的引用:

harrypotter -> doc1, doc3
luceneinaction -> doc2
每个术语都指向您可以在上面看到的文档

如果您需要获取每个文档的术语,请通过所需的分析器分别运行它们。

Lucene是一个,因此它存储对术语的引用,如下所示:

harrypotter -> doc1, doc3
luceneinaction -> doc2
每个术语都指向您可以在上面看到的文档

如果您需要获取每个文档的术语,请通过所需的分析器分别运行它们。

Lucene是一个,因此它存储对术语的引用,如下所示:

harrypotter -> doc1, doc3
luceneinaction -> doc2
每个术语都指向您可以在上面看到的文档

如果您需要获取每个文档的术语,请通过所需的分析器分别运行它们。

Lucene是一个,因此它存储对术语的引用,如下所示:

harrypotter -> doc1, doc3
luceneinaction -> doc2
每个术语都指向您可以在上面看到的文档


如果您需要获取每个文档的术语,请通过所需的分析器分别运行它们。

它将为您提供唯一的术语。但是,您可以通过以下方式获得包含该术语的文档的计数:

while ((byteRef = iterator.next()) != null) {
    System.out.println(byteRef.utf8ToString() + " - " + iterator.docFreq());
}

它会给你独特的条款。但是,您可以通过以下方式获得包含该术语的文档的计数:

while ((byteRef = iterator.next()) != null) {
    System.out.println(byteRef.utf8ToString() + " - " + iterator.docFreq());
}

它会给你独特的条款。但是,您可以通过以下方式获得包含该术语的文档的计数:

while ((byteRef = iterator.next()) != null) {
    System.out.println(byteRef.utf8ToString() + " - " + iterator.docFreq());
}

它会给你独特的条款。但是,您可以通过以下方式获得包含该术语的文档的计数:

while ((byteRef = iterator.next()) != null) {
    System.out.println(byteRef.utf8ToString() + " - " + iterator.docFreq());
}

这似乎不是主要问题。你到底想做什么?这似乎不是主要问题。你到底想做什么?这似乎不是主要问题。你到底想做什么?这似乎不是主要问题。你到底想干什么?