Dhima
Dhima

Reputation: 3

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.

Upvotes: 0

Views: 733

Answers (1)

BunkerMentality
BunkerMentality

Reputation: 1337

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)

Upvotes: 1

Related Questions