脚本宝典收集整理的这篇文章主要介绍了zend-framework – 具有相同性质的多个字段的Lucene索引,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
我努力寻找成分,并给出一个结果,说两个成分匹配四个. (例如)
那么如何将这些成分添加到doc中呢?在solr我可以创建多个字段,它会将它们全部保存,我可能做错了,因为它只保存了一个成分.
这也适用于像’tags’这样的字段.
document.add(new Field("name"),value)
所以你这样做:
# (pseudo-code) document1.add(new Field("ingredient"),"vanilla") document1.add(new Field("ingredient"),"strawBerry") index.add(document) # And then seArch for index.search("ingredient","vanilla" && "strawBerry")
index.search("ingredient","vanilla" && "apple")
你不会得到document1.
如果您搜索:
index.search("ingredient","vanilla" || "apple")
你也可以找回document1.
如果要查看哪些成分匹配,只需将文档上的字段保存为存储字段,然后为每个匹配的文档检索字段列表并将其与用户查询进行比较.
另请注意,默认情况下,添加到文档的具有相同名称的字段的PosITionIncrementGap为0.
这意味着,如果你添加:
document1.add(new Field("ingredient"),"chocolate") document1.add(new Field("ingredient"),"orange")
然后它会被视为一种叫做“巧克力橙”的单一成分,可能与之匹配:
index.search("ingredient","chocolate orange")
你可以避免为PositionIncrementGap>设置一个值. 1,将产生:
0场比赛:
index.search("ingredient","chocolate orange")
和1匹配:
index.search("ingredient","chocolate" && "orange")
以上是脚本宝典为你收集整理的zend-framework – 具有相同性质的多个字段的Lucene索引全部内容,希望文章能够帮你解决zend-framework – 具有相同性质的多个字段的Lucene索引所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。