PHP Zend Lucene 具有多个条件的搜索查询失败
Zend Lucene 搜索文档
Lucene Document pk:Keyword category_id:Keyword title:UnStored description:UnStored
这是我的字符串查询“java lucene AND +category_id:7”。 结果如下:
Array ( [0] => Array ( [pk] => 209 [category_id] => 7 [id] => 0 [score] => 0.40750848701418 ) [1] => Array ( [pk] => 225 [category_id] => 7 [id] => 3 [score] => 0.30750848701619 ) [2] => Array ( [pk] => 211 [category_id] => 8 ====>>> WRONG!!! [id] => 2 [score] => 0.37152213415004 ) )
您可以仅对category_id = 7 进行查询搜索吗? 提前致谢。
Zend Lucene Search Document
Lucene Document pk:Keyword category_id:Keyword title:UnStored description:UnStored
This is my string query "java lucene AND +category_id:7".
Result here:
Array ( [0] => Array ( [pk] => 209 [category_id] => 7 [id] => 0 [score] => 0.40750848701418 ) [1] => Array ( [pk] => 225 [category_id] => 7 [id] => 3 [score] => 0.30750848701619 ) [2] => Array ( [pk] => 211 [category_id] => 8 ====>>> WRONG!!! [id] => 2 [score] => 0.37152213415004 ) )
Can you do a Query search on the category_id = 7 only??
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我已经通过使用 Zend 查询解析结果解决了这个问题,
结果将仅在category_id = 7中:)
I had solved this problem by using Zend Query Parsing
Results will be only in category_id = 7 :)
您可以从查询中删除
AND +category_id:7
,您想要的是一个过滤器,因为不需要+category_id:7
作为排名值。我不知道如何用
Zend_Lucene
实现它,但在 solr 中我曾经传递 fq 参数,这可能会给你一个提示:)过滤是一个限制搜索空间并只允许子集的过程考虑搜索命中的文档。您可以使用此功能来实现搜索结果中的搜索。 Lucene自带各种内置过滤器如BooleanFilter、CachingWrapperFilter、ChainedFilter、DuplicateFilter、PrefixFilter、QueryWrapperFilter、RangeFilter、RemoteCachingWrapperFilter、SpanFilter等(THE NATIVE JAVA VERSION)过滤器可以传递给IndexSearcher的搜索方法来过滤符合过滤条件的文档。
You can remove the
AND +category_id:7
from you query, what you want is a filter since+category_id:7
is not needed as a ranked value.I don't know how to implement it with
Zend_Lucene
but in solr I used to pass fq parameter, this may give you a hint :)Filtering is a process that constrains the search space and allows only a subset of documents to be considered for search hits. You can use this feature to implement search-within-search results. Lucene comes with various built-in filters such as BooleanFilter, CachingWrapperFilter, ChainedFilter, DuplicateFilter, PrefixFilter, QueryWrapperFilter, RangeFilter, RemoteCachingWrapperFilter, SpanFilter, etc.(THE NATIVE JAVA VERSION) Filter can be passed to IndexSearcher's search method to filter documents that match the filter criteria.