2012-12-06 26 views
1

當我查詢字符串的多個字段時,是否可以檢索查詢字段在哪個字段中找到的信息?Solr/Lucene獲取找到結果的字段

我想查詢描述,信息,附加信息......但是,然後我需要知道哪個字段給出了結果因爲我想給不同的佈局。

回答

1

Lucene的方式:看IndexSearcher.explain(...)。這將給出描述doc如何針對query得分的Explanation

Solr的方式:加&debugQuery=true。我查詢了collection:61並得到了這份文件:

<doc> 
    <str name="collection">61</str> 
    ...other fields... 
    <long name="uuid">1111</long> 
</doc> 

,然後在下面談到這個

<lst name="explain"> 
    <str name="1111"> 
    0.882217 = (MATCH) fieldWeight(collection:61 in 0), product of: 1.0 = 
    tf(termFreq(collection:61)=1) 0.882217 = idf(docFreq=8, maxDocs=8) 1.0 = 
    fieldNorm(field=collection, doc=0) 
    </str> 
    ... 
</lst> 

以上基本上告訴該項目1111有場collection與價值61。您也可以請求debug.explain.structured以更加結構化的格式獲取此解釋字符串。