Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/309.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 Lucene:Topdocs索引搜索返回零_Java_Lucene - Fatal编程技术网

Java Lucene:Topdocs索引搜索返回零

Java Lucene:Topdocs索引搜索返回零,java,lucene,Java,Lucene,测试结果为零。这可能是什么原因造成的 我相信我为indexsearcher设置了正确的路径 我想我已经创建了正确的索引文件 问题解决了。我使用Stringfield而不是“textfield”进行搜索。 应该是文本字段。它是为关键字搜索而设计的。result=0表示它没有找到任何点击。我们不能告诉你更像这个显而易见的答案。您可以搜索不在索引中的术语,或者您的索引可能为空。谁知道呢。 Query q = parser.parse(query); //Checked;Syst

测试结果为零。这可能是什么原因造成的

  • 我相信我为indexsearcher设置了正确的路径
  • 我想我已经创建了正确的索引文件

  • 问题解决了。我使用Stringfield而不是“textfield”进行搜索。
    应该是文本字段。它是为关键字搜索而设计的。

    result=0表示它没有找到任何点击。我们不能告诉你更像这个显而易见的答案。您可以搜索不在索引中的术语,或者您的索引可能为空。谁知道呢。
    Query q = parser.parse(query);
                //Checked;System.out.println(q);
                TopDocs hits = searcher.search(q,numResultsToReturn);
                int test = hits.totalHits;
                System.out.println(test);