简体   繁体   中英

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 ?

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

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

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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