简体   繁体   English

使用Apache SOLR进行高级搜索

[英]Advanced search with Apache SOLR

I have a problem to filter data. 我有一个过滤数据的问题。 I already have a data that contain size per product. 我已经有一个包含每个产品尺寸的数据。

{"product_name":"new jeans","product_size_url":"27"},
{"product_name":"new sporty shoes ","product_size_url":"39"},
{"product_name":"new shoes ","product_size_url":"45"}

How do I build the query to show data that contains size 27,45 ? 如何构建查询以显示包含27,45大小的数据?

I Really need help for this case. 对于这种情况,我确实需要帮助。 Thanks. 谢谢。

You already have a query that returns size per product? 您已经有一个查询,返回每个产品的尺寸? If you don't want your size query to affect the relevancy scores of your query use a filter query - fq 如果您不希望大小查询影响查询的相关性得分,请使用过滤器查询-FQ

This parameter can be used to specify a query that can be used to restrict the super set of documents that can be returned, without influencing score. 此参数可用于指定查询,该查询可用于限制可以返回的超级文档集,而不会影响得分。 It can be very useful for speeding up complex queries since the queries specified with fq are cached independently from the main query 由于用fq指定的查询是独立于主查询进行缓存的,因此对于加快复杂查询的速度非常有用。

https://wiki.apache.org/solr/CommonQueryParameters#fq https://wiki.apache.org/solr/CommonQueryParameters#fq

So you would query like this 所以你会这样查询

q=product_name:new&fq=product_size_url:(27 OR 45)

That would find all products with the word new in the name and then restrict the super set by applying the filter query product_size_url:(27 OR 45) 这将找到名称中带有单词new的所有产品,然后通过应用过滤器查询product_size_url:(27 OR 45)限制超级集。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM