You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by steve berry <sb...@bizjournals.com> on 2008/03/04 21:34:47 UTC
Question about facet.prefix usage
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
Re: Question about facet.prefix usage
Posted by Ryan McKinley <ry...@gmail.com>.
steve berry wrote:
>
> 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
>
No (unless you want to write your own SimpleFacets subclass)
>
> 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.
>
perhaps you could have two fields: city and year
then to limit access to 2006 or 2007, you would add a filter query:
fq=year:2006 OR year:2007
ryan
Re: Question about facet.prefix usage
Posted by Peter Cline <pc...@pobox.upenn.edu>.
Hi Simon,
I came across your post to the solr users list about using facet
prefixes, shown below. I was wondering if you were still using your
modified version of SimpleFacets.java, and if so -- if you could send me
a copy. I'll need to implement something similar, and it never hurts to
start from existing material.
Thanks,
Peter
Simon Hu wrote:
> I also need the exact same feature. I was not able to find an easy solution
> and ended up modifying class SimpleFacets to make it accept an array of
> facet prefixes per field. If you are interested, I can email you the
> modified SimpleFacets.java.
>
> -Simon
>
>
> steve berry-2 wrote:
>
>> 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
>>
>>
>>
>>
>>
>
>
Re: Question about facet.prefix usage
Posted by Simon Hu <si...@grainger.com>.
You are right. I got it confused with fq (you can tell I am relative new to
solr :-) ). Thanks for the clarification.
Anyway, facet.query will not do the trick. I wanted to do a facet count on
all values starting with more than one prefix in the same field. Doing
something like:
f.field1.facet.prefix=patternA&f.field1.facet.prefix=patternB
the facet count in the result would look like the following:
<lst name="field1">
<int name="patternA xxx">7</int>
<int name="patternA yyy">1</int>
<int name="patternB zzz">2</int>
</lst>
Field values not starting with "patternA" or "patterB" will not be counted.
Erik Hatcher wrote:
>
> To be clear here, facet.query does not filter the result set at all.
> It provides a count for how many documents in the current result set
> (determined by q/fq parameters, oh, and bq sometimes too, doh! :)
> match that query.
>
> Erik
>
>
>
> On Sep 30, 2008, at 9:42 PM, Simon Hu wrote:
>
>>
>> not really. facet.query filters the result set. Here we need to
>> filter the
>> facet counts by multiple facet prefixes. facet.query would work only
>> if the
>> faceted field is not a multi-value field.
>>
>>
>>
>> Erik Hatcher wrote:
>>>
>>> If I'm not mistaken, doesn't facet.query accomplish what you want?
>>>
>>> Erik
>>>
>>>
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Question-about-facet.prefix-usage-tp15836501p19753290.html
>> Sent from the Solr - User mailing list archive at Nabble.com.
>
>
>
--
View this message in context: http://www.nabble.com/Question-about-facet.prefix-usage-tp15836501p19761563.html
Sent from the Solr - User mailing list archive at Nabble.com.
Re: Question about facet.prefix usage
Posted by Erik Hatcher <er...@ehatchersolutions.com>.
To be clear here, facet.query does not filter the result set at all.
It provides a count for how many documents in the current result set
(determined by q/fq parameters, oh, and bq sometimes too, doh! :)
match that query.
Erik
On Sep 30, 2008, at 9:42 PM, Simon Hu wrote:
>
> not really. facet.query filters the result set. Here we need to
> filter the
> facet counts by multiple facet prefixes. facet.query would work only
> if the
> faceted field is not a multi-value field.
>
>
>
> Erik Hatcher wrote:
>>
>> If I'm not mistaken, doesn't facet.query accomplish what you want?
>>
>> Erik
>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/Question-about-facet.prefix-usage-tp15836501p19753290.html
> Sent from the Solr - User mailing list archive at Nabble.com.
Re: Question about facet.prefix usage
Posted by Simon Hu <si...@grainger.com>.
not really. facet.query filters the result set. Here we need to filter the
facet counts by multiple facet prefixes. facet.query would work only if the
faceted field is not a multi-value field.
Erik Hatcher wrote:
>
> If I'm not mistaken, doesn't facet.query accomplish what you want?
>
> Erik
>
>
>
--
View this message in context: http://www.nabble.com/Question-about-facet.prefix-usage-tp15836501p19753290.html
Sent from the Solr - User mailing list archive at Nabble.com.
Re: Question about facet.prefix usage
Posted by Erik Hatcher <er...@ehatchersolutions.com>.
If I'm not mistaken, doesn't facet.query accomplish what you want?
Erik
On Sep 29, 2008, at 5:43 PM, Simon Hu wrote:
>
> I also need the exact same feature. I was not able to find an easy
> solution
> and ended up modifying class SimpleFacets to make it accept an array
> of
> facet prefixes per field. If you are interested, I can email you the
> modified SimpleFacets.java.
>
> -Simon
>
>
> steve berry-2 wrote:
>>
>>
>> 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
>>
>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/Question-about-facet.prefix-usage-tp15836501p19732310.html
> Sent from the Solr - User mailing list archive at Nabble.com.
Re: Question about facet.prefix usage
Posted by Simon Hu <si...@grainger.com>.
I also need the exact same feature. I was not able to find an easy solution
and ended up modifying class SimpleFacets to make it accept an array of
facet prefixes per field. If you are interested, I can email you the
modified SimpleFacets.java.
-Simon
steve berry-2 wrote:
>
>
> 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
>
>
>
>
--
View this message in context: http://www.nabble.com/Question-about-facet.prefix-usage-tp15836501p19732310.html
Sent from the Solr - User mailing list archive at Nabble.com.