Question

i have an array of products. For each product I have to crate an solr faceted search.

Example for the following "products":

Computer
TV
MP3-Player

by using faceted search I like to determine, how often every product exists in field PRODUCT. With the following result

Comupter (3)
  -apple
  -ibm
  -dell
TV (5)
  -sony
  -toshiba
  [...]
MP3-player (10)
  -[...]

Right now, i realize that by using one faceted search for every word/product. That works, but the results returned in 400ms by using the following options:

'facet' => 'true'
'facet.field' => 'PRODUCT'
'facet.method' => 'enum'
 'facet.limit'=>200
'facet.mincount'=>4
 'fq' => 'PRODUCT:computer'    <- by iterating an array with PHP i change the product (computer,tv,...) on every iteration

Unfortunately in real life there are not 3 product (like the example above), there are round about 100 products, which are relevant. That means: the PHP script hast to request 100 solr searches, with 400ms - so the script runs 40 seconds, which is to long. I'm unable to run an unlimited/unrestricted faceted search for "all" products (without "fq="), because there are thousend of products and I dont need the information only fro a every.

Is there a way to realize a better performance for example be merge those multiple solr requests into one?

Thank you!

Was it helpful?

Solution

I didn't quite get that, but can't you just create one filter query for the products that are relevant to the query:

facet' => 'true'
'facet.field' => 'PRODUCT'
'facet.method' => 'enum'
'facet.limit'=>200
'facet.mincount'=>4
'fq' => 'PRODUCT:(computer OR tv OR mp3-player)'

And then do some processing on the returned results?

OTHER TIPS

You usually don't want to filter on a specific type value when faceting. The idea behind faceting is that it will do a "group" and "count" for all values in the faceted field (for all items that matches the original query).

If you simply remove your fq-parameter you will see that in return you will get a list of all values in PRODUCT-field that occur at least 4 times and the count for each of those values.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top