当我查询一个字符串的多个字段时,是否可以检索在哪个字段中找到查询词的信息?
我想查询描述、信息、附加信息……但是我需要知道哪个字段给出了结果,因为我想给出不同的布局。
Lucene方式:看IndexSearcher.explain(...). 这将给出一个Explanation描述如何doc对query.
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 有字段collectionvalue 61。您还可以请求debug.explain.structured以更结构化的格式获取此解释字符串。