Pre Exam Test Practice (SSC | Banking | IAS | GATE | State Level | CLAT | Railways | Insurance | Teaching Exams | NDA | Defence | IES |State Exam )

Organizational Research By

Surprising Reserch Topic

Filter irrelevant facets from Solr results

I've spent hours poking around for a solution to my problem. I've seen people ask questions close to what I'm trying to accomplish, but so far no one seems to be asking the same question. Let me see if I can explain this adequately:

Say I'm a shoe store. On my web site I have three pages: one for men's shoes, one for women's shoes and one for kid's shoes. Let's say my shoe table has the field prod_group. So for the men's page the query would be q=prod_group:men. Now let's say one of the facets I want to provide is brand. q=prod_group:men&filter.field=brand

The issue I'm having is the facet results are showing all brands in my database, not just brands relevant to men's shoes. In other words, I already know that there are zero men's shoes in the "My Little Pony" line. I don't want to display My Little Pony in the brand facet. Setting facet.mincount isn't what I need either. If I run a query q=prod_group:men&fq=color:red&filter.field=brand, the client wants to show the consumer that the brand "Mighty Joe" doesn't have any red shoes so I still need facets with a facet count of 0.

Basically what I'm hoping for is facet results based on the results from the base query. So far the only way I see to accomplish this is to run two queries: the first with just the base query and setting facet.mincount = 1 to get a list of relevant facets and then the actual query with facet.mincount back to 0 so I can figure out when to grey out certain options that are no longer available based on facet choices already made.

Running two queries seems somewhat less than elegant. facet.pivot might help in the long run, but we're still using 3.x and I don't see that changing any time soon. Have I missed some query/schema/configuration option that will do what I need with one query?

asked May 16, 2015 in SOLR by rajesh
0 votes

Related Hot Questions

Government Jobs Opening