2011-04-13 64 views
0

我创建了一个存储短信的索引(使用Lucene 2.9)。 (这些文档还包含一些其他的未被索引的元数据,只是存储)我使用StandardAnalyzer来解析这些消息。我试图用Solr对这个索引运行一些测试(我用我的索引替换了示例应用索引),以查看从各种查询中得到的结果。Solr queryparser的lucene索引?

当我试图下面的查询,我得到0的结果

"text:happiness" 

然而,改变的是对"text:happiness*"给了我一定的成效。所有这些都包含像"happiness,", "happiness."等术语等。所以我认为它是索引创建过程中的一个标记化问题,但是,当我使用Luke(一个lucene索引调试工具)运行相同的查询(text:happiness)时,我得到了完全相同的结果,即I从Solr那里获得快乐*,这让我相信这个问题不是在编制索引时,而是以我指定我的Solr查询的方式。我查看了solrconfig.xml,并注意到它有下面一行(注释),我试着取消它的注释,然后修改我的查询以除原始查询外使用“defType = lucene”,但得到了相同的结果。

<queryParser name="lucene" class="org.apache.solr.search.LuceneQParserPlugin"/> 

我有Solr的经验非常少,所以任何帮助是极大的赞赏:)

+0

我可以通过更改我的solrconfig.xml来解决此问题 – fsm 2011-04-13 22:27:17

+0

您可以将解决方案作为答案发布并接受它。 – 2011-04-13 22:35:13

+0

我发布了我的解决方案,我必须等待2天才能接受它。 – fsm 2011-04-14 01:15:51

回答

0

,我被查询的字段定义为在Solr的schema.xml中键入“文本”(不solrconfig .xml,因为我在之前的评论中错误地提到过)。下面是来自schema.xml中

<fieldType name="text" class="solr.TextField" positionIncrementGap="100"> 
     <analyzer type="index"> 
     <tokenizer class="solr.WhitespaceTokenizerFactory"/> 
     <!-- in this example, we will only use synonyms at query time 
     <filter class="solr.SynonymFilterFactory" synonyms="index_synonyms.txt" ignoreCase="true" expand="false"/> 
     --> 
     <!-- Case insensitive stop word removal. 
      add enablePositionIncrements=true in both the index and query 
      analyzers to leave a 'gap' for more accurate phrase queries. 
     --> 

我用下面的取代它相关的片段,

<fieldType name = "text" class="solr.TextField"> 
     <analyzer class="org.apache.lucene.analysis.standard.StandardAnalyzer"/> 
    </fieldType> 

这给了我所需要的行为。