Question: Is it possible to pass complex queries to facet.prefix? Example instead of facet.prefix:foo I want facet.prefix:foo OR facet.prefix:bar

My application is for browsing business records that fall into categories. The user is only allowed to see businesses falling into categories which they have access to.

I have a series of documents dumped into the following basic structure which I was hoping would help me deal with this:

<doc>
   <field name="id">123</field>
   <field name="name">Business Corp.</field>
   <field name="zip">28255-0001</field>
   .....
   <field name="market_category">charlotte_2006 Banks</field>
   <field name="market_category">charlotte_2007 Banks</field>
   <field name="market_category">sanfrancisco_2006 Banks</field>
   <field name="market_category">sanfrancisco_2007 Banks</field>
   ... (lots more market_category entries) ...
</doc>
<doc>
   <field name="id">124</field>
   <field name="name">Factory Corp.</field>
   <field name="zip">28205-0001</field>
   .....
   <field name="market_category">charlotte_2006 Banks</field>
   <field name="market_category">charlotte_2007 Banks</field>
   <field name="market_category">austin_2006 Banks</field>
   <field name="market_category">austin_2007 Banks</field>
   ... (lots more market_category entries) ...
</doc>
.....

The multivalued market_category fields are flattened relational data attributed to that business and I want to use those values for facted navigation /but/ I want the facets to be restricted depending on what products the user has access to. For example a user may have access to sanfrancisco_2007 and sanfrancisco_2006 data but nothing else.

So I've created a request using facet.prefix that looks something like this:
http://SOLRSERVER:8080/solr/select?q.op=AND&q=docType:gen&facet.field=market_category&facet.prefix=charlotte_2007

This ends up producing perfectly suitable facet results that look like this:
......
<lst name="facet_queries"/>
   <lst name="facet_fields">
   <lst name="market_category">
<int name="charlotte_2007 Banks/Financial Institutions">1</int>
<int name="charlotte_2007 Employers">1</int>
<int name="charlotte_2007 Highest-Paid Executives/Public Officials/Athletes">1</int>
<int name="charlotte_2007 Mergers  Acquisitions">1</int>
<int name="charlotte_2007 Miscellaneous">1</int>
<int name="charlotte_2007 Public Companies">1</int>
<int name="charlotte_2007">0</int>
</lst>
.....


Bingo! facet.prefix does exactly what I want it to.

Now I want to go a step further and pass a compound statement to the facet.prefix along the lines of "facet.prefix:charlotte_2007 OR sanfrancisco_2007" or "facet.prefix:charlotte_2007 OR charlotte_2006" to return more complex facet sets. As far as I can tell looking at the docs this won't work.

Is this possible using the existing facet.prefix functionality? Anyone have a better idea of how I should accomplish this?

Thanks,
steve berry
American City Business Journals


Reply via email to