You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Nicola Buso <nb...@ebi.ac.uk> on 2013/01/29 18:29:46 UTC
FacetRequest include residue
Hi,
I have a FacetRequest with numResults setted to 10, how can I specify
additional facets value to add to the FacetResult?
I try to explain the use-case:
- the user view 10 facet result
- the interface permit the user to choose a facet value not from the
top-10 results
- the user execute the query with the facet value not in the top-10
- I'd like to show in the list of facet value also the value selected by
the user.
The only way I see I can obtain this value is execute a query where I'm
not restricting the number of facet values returned and I "cherry pick"
the facet with the value I need. Obviously it's costly.
Nicola.
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
Re: FacetRequest include residue
Posted by Nicola Buso <nb...@ebi.ac.uk>.
Hi Shai,
your solution sound good to me, an accumulator that can add in the
counting some "exception".
Nicola.
On Wed, 2013-01-30 at 08:13 +0200, Shai Erera wrote:
> Hi Nicola,
>
>
> There might be a way to do what you want, with some coding on your
> part. If you're interested in counting the top-10 of the "Brand"
> facet, but also return the count of "Brand/X", even if it's not in the
> top-10, then what you should do is write code similar to this:
>
>
> FacetArrays facetArrays = new FacetArrays();
>
> int[] counts = facetArrays.getIntArray(); // hold onto the counts
> array, so that it's not "released" by the Collector
>
> FacetsCollector fc = new FacetsCollector(..., facetArrays); // tell
> the collector to use your array
>
> searcher.search(q, fc);
>
> List<FacetResults> facetResults = fc.getFacetResults();
>
>
> // now you should get the FacetResult of "Brand" and check if Brand/X
> is in its FacetResultNodes (top-10)
>
> // if not, do the following:
>
> int brandXOrdinal = taxoReader.getOrdinal(new CategoryPath("Brand",
> "X");
>
> int brandXCount = counts[brandXOrdinal];
>
>
> // now you can build your final result with the count of Brand/X
>
>
> Hope that helps
>
> Shai
>
>
>
> On Tue, Jan 29, 2013 at 7:55 PM, Shai Erera <se...@gmail.com> wrote:
> Hi Nicola,
>
>
> How does the interface allow the user to select a facet values
> not from the top-10? How does the interface know which other
> facet values are there? Does it query the taxonomy somehow?
>
>
> One thing you can do is to set numResults to Integer.MAX_VALUE
> and numToLabel to 10. That way your FacetResult will have all
> the children up to the specified depth, but only the top-10
> will be labeled (which can sometimes be costly). I'm not sure
> if that's what you're looking for?
>
>
> And again, this might be something that you can do in the UI
> -- add the value that the user selected to the list of values
> that are displayed, irregardless of what the top-10 are?
>
>
> Shai
>
>
>
> On Tue, Jan 29, 2013 at 7:29 PM, Nicola Buso <nb...@ebi.ac.uk>
> wrote:
> Hi,
>
> I have a FacetRequest with numResults setted to 10,
> how can I specify
> additional facets value to add to the FacetResult?
>
> I try to explain the use-case:
> - the user view 10 facet result
> - the interface permit the user to choose a facet
> value not from the
> top-10 results
> - the user execute the query with the facet value not
> in the top-10
> - I'd like to show in the list of facet value also the
> value selected by
> the user.
>
> The only way I see I can obtain this value is execute
> a query where I'm
> not restricting the number of facet values returned
> and I "cherry pick"
> the facet with the value I need. Obviously it's
> costly.
>
>
>
> Nicola.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail:
> java-user-help@lucene.apache.org
>
>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
Re: FacetRequest include residue
Posted by Shai Erera <se...@gmail.com>.
Hi Nicola,
There might be a way to do what you want, with some coding on your part. If
you're interested in counting the top-10 of the "Brand" facet, but also
return the count of "Brand/X", even if it's not in the top-10, then what
you should do is write code similar to this:
FacetArrays facetArrays = new FacetArrays();
int[] counts = facetArrays.getIntArray(); // hold onto the counts array, so
that it's not "released" by the Collector
FacetsCollector fc = new FacetsCollector(..., facetArrays); // tell the
collector to use your array
searcher.search(q, fc);
List<FacetResults> facetResults = fc.getFacetResults();
// now you should get the FacetResult of "Brand" and check if Brand/X is in
its FacetResultNodes (top-10)
// if not, do the following:
int brandXOrdinal = taxoReader.getOrdinal(new CategoryPath("Brand", "X");
int brandXCount = counts[brandXOrdinal];
// now you can build your final result with the count of Brand/X
Hope that helps
Shai
On Tue, Jan 29, 2013 at 7:55 PM, Shai Erera <se...@gmail.com> wrote:
> Hi Nicola,
>
> How does the interface allow the user to select a facet values not from
> the top-10? How does the interface know which other facet values are there?
> Does it query the taxonomy somehow?
>
> One thing you can do is to set numResults to Integer.MAX_VALUE and
> numToLabel to 10. That way your FacetResult will have all the children up
> to the specified depth, but only the top-10 will be labeled (which can
> sometimes be costly). I'm not sure if that's what you're looking for?
>
> And again, this might be something that you can do in the UI -- add the
> value that the user selected to the list of values that are displayed,
> irregardless of what the top-10 are?
>
> Shai
>
>
> On Tue, Jan 29, 2013 at 7:29 PM, Nicola Buso <nb...@ebi.ac.uk> wrote:
>
>> Hi,
>>
>> I have a FacetRequest with numResults setted to 10, how can I specify
>> additional facets value to add to the FacetResult?
>>
>> I try to explain the use-case:
>> - the user view 10 facet result
>> - the interface permit the user to choose a facet value not from the
>> top-10 results
>> - the user execute the query with the facet value not in the top-10
>> - I'd like to show in the list of facet value also the value selected by
>> the user.
>>
>> The only way I see I can obtain this value is execute a query where I'm
>> not restricting the number of facet values returned and I "cherry pick"
>> the facet with the value I need. Obviously it's costly.
>>
>>
>>
>> Nicola.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
>> For additional commands, e-mail: java-user-help@lucene.apache.org
>>
>>
>
Re: FacetRequest include residue
Posted by Shai Erera <se...@gmail.com>.
Hi Nicola,
How does the interface allow the user to select a facet values not from the
top-10? How does the interface know which other facet values are there?
Does it query the taxonomy somehow?
One thing you can do is to set numResults to Integer.MAX_VALUE and
numToLabel to 10. That way your FacetResult will have all the children up
to the specified depth, but only the top-10 will be labeled (which can
sometimes be costly). I'm not sure if that's what you're looking for?
And again, this might be something that you can do in the UI -- add the
value that the user selected to the list of values that are displayed,
irregardless of what the top-10 are?
Shai
On Tue, Jan 29, 2013 at 7:29 PM, Nicola Buso <nb...@ebi.ac.uk> wrote:
> Hi,
>
> I have a FacetRequest with numResults setted to 10, how can I specify
> additional facets value to add to the FacetResult?
>
> I try to explain the use-case:
> - the user view 10 facet result
> - the interface permit the user to choose a facet value not from the
> top-10 results
> - the user execute the query with the facet value not in the top-10
> - I'd like to show in the list of facet value also the value selected by
> the user.
>
> The only way I see I can obtain this value is execute a query where I'm
> not restricting the number of facet values returned and I "cherry pick"
> the facet with the value I need. Obviously it's costly.
>
>
>
> Nicola.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>