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 AlexR <al...@hotmail.com> on 2012/06/22 15:32:26 UTC

alphanumeric interval

Hallo,

i have a problem and don't know how to fix it.
for a project i need intervals over a field of alphanumeric content.

For example i have a field with names (100 different names) and i need 4
Intervals
Alex
Andreas
Ben
Christian
Daniel....

I need even sized buckets and their borders. 
100/4 = 25 entries

Border for first interval is entry 1 and entry 25
in this case Alex - John

i don't want to load all names and calculate the borders on the client.
Is there a way to get the borders from Solr?

kind regards



--
View this message in context: http://lucene.472066.n3.nabble.com/alphanumeric-interval-tp3990965.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: alphanumeric interval

Posted by Cat Bieber <cb...@techtarget.com>.
I did not use facets in my implementation, so I don't have any 
facet-specific code snippet that would be helpful to you. However, if 
your handler extends SearchHandler and calls super.handleRequestBody() 
it should be running the facet component code. You have access to the 
SolrQueryResponse built by it, and may be able to get the data out of 
that object. You'll need to look at the javadoc for NamedList, and I 
found it helpful to dump the list in debug statements so I could examine 
its structure and contents. I suspect you need something like 
rsp.getValues().get("facet_counts") to get the facet data, but haven't 
tested it.
-Cat Bieber

On 07/05/2012 04:32 AM, AlexR wrote:
> Hi,
>
> thanks a lot for your answer, and sorry for my late response.
>
> It's my first time to write a solr plugin. I already have a plugin with
> empty handleRequestBody() method and i'm able to call them.
>
> I need the list of facetted field person (facet.field=person) in my method.
> but i don't know how.
>
> do you have a code snipped of your implementation?
>
> thx
> Alex
>
>
> --
> View this message in context: http://lucene.472066.n3.nabble.com/alphanumeric-interval-tp3990965p3993148.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>    

Re: alphanumeric interval

Posted by AlexR <al...@hotmail.com>.
Hi,

thanks a lot for your answer, and sorry for my late response.

It's my first time to write a solr plugin. I already have a plugin with
empty handleRequestBody() method and i'm able to call them.

I need the list of facetted field person (facet.field=person) in my method.
but i don't know how.

do you have a code snipped of your implementation?

thx
Alex
 

--
View this message in context: http://lucene.472066.n3.nabble.com/alphanumeric-interval-tp3990965p3993148.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: alphanumeric interval

Posted by Cat Bieber <cb...@techtarget.com>.
I had a similar issue. The solution I ended up using was a custom 
RequestHandler that extends SearchHandler. In handleRequestBody() it 
calls super.handleRequestBody(req, rsp), looks for a "pageSize" 
parameter (25 in your example), and loops over the array of results 
inside the response, pulling out the ones I want and building a new 
array. It performs well enough, and avoids downloading a large result 
set. It sounds like you're more interested in number of buckets whereas 
I needed a specific page size, but you could just as easily pass in the 
number of buckets in your param. This solution does require that you be 
willing to write some java code and add it to your solr deploy as a 
plugin. Then you configure your new request handler in solrconfig.xml 
and you can give it a default page size or bucket size.

I actually discussed this with some people at the training before Lucene 
Revolution and there wasn't a distinct right answer. Because I was 
looking for a three-letter prefix for my ranges, one suggestion was to 
add the prefix to the solr index and facet on it. Then, by adding up 
counts you could tell what the endpoints of an interval were. That would 
still require doing some calculations on the client side, and it won't 
be useful if you have full values with few duplicates.
-Cat Bieber


On 06/22/2012 09:32 AM, AlexR wrote:
> I need even sized buckets and their borders.
> 100/4 = 25 entries
>
> Border for first interval is entry 1 and entry 25
> in this case Alex - John
>
> i don't want to load all names and calculate the borders on the client.
> Is there a way to get the borders from Solr?
>
>