You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-dev@lucene.apache.org by Grant Ingersoll <gs...@apache.org> on 2009/08/28 16:26:52 UTC

Mucking with DocSlices

I'd like to be able to change the DocList in a SearchComponent, for  
instance to shorten or lengthen it.  I can get a shorter one via the  
subset() method, but the problem with this is the new subset still  
reflects the number of matches, etc. of the parent, which seems a  
little odd to me.  If I say String.substring().length(), I wouldn't  
expect the length returned to be the same as the parent (unless of  
course the substring requested is the identity one), so I'm not sure  
why DocSlice.subset does.  Likewise for the maxScore, etc.

Is there a reason why, if I know I have a DocSlice, I can't cast the  
docList to it and make some of these lower level changes to the member  
variables?  It would be a lot more efficient than having to copy over  
all the docs, etc. to a new DocSlice.

Thanks,
Grant

Re: Mucking with DocSlices

Posted by Grant Ingersoll <gs...@apache.org>.
On Aug 28, 2009, at 1:03 PM, Yonik Seeley wrote:

> On Fri, Aug 28, 2009 at 10:26 AM, Grant  
> Ingersoll<gs...@apache.org> wrote:
>>  If I say
>> String.substring().length(), I wouldn't expect the length returned  
>> to be the
>> same as the parent (unless of course the substring requested is the  
>> identity
>> one), so I'm not sure why DocSlice.subset does.
>
> .size() should reflect the new size.
> .matches() always reflects the total number of matches that this
> DocList is a window into.
>
>>  Likewise for the maxScore,
>> etc.
>>
>> Is there a reason why, if I know I have a DocSlice, I can't cast  
>> the docList
>> to it and make some of these lower level changes to the member  
>> variables?
>>  It would be a lot more efficient than having to copy over all the  
>> docs,
>> etc. to a new DocSlice.
>
> Just make a new DocSlice - one shouldn't be modifying these since they
> can be cached.

Sure, but that requires creating a new int [] doc array, copying  
elements, etc. all over again and I may not need to do that (for  
instance, if I am shortening the list based on some business rules)

My solution so far is a light weight wrapper around DocList that seems  
to be working just fine.

Re: Mucking with DocSlices

Posted by Yonik Seeley <ys...@gmail.com>.
On Fri, Aug 28, 2009 at 10:26 AM, Grant Ingersoll<gs...@apache.org> wrote:
>  If I say
> String.substring().length(), I wouldn't expect the length returned to be the
> same as the parent (unless of course the substring requested is the identity
> one), so I'm not sure why DocSlice.subset does.

.size() should reflect the new size.
.matches() always reflects the total number of matches that this
DocList is a window into.

> Likewise for the maxScore,
> etc.
>
> Is there a reason why, if I know I have a DocSlice, I can't cast the docList
> to it and make some of these lower level changes to the member variables?
>  It would be a lot more efficient than having to copy over all the docs,
> etc. to a new DocSlice.

Just make a new DocSlice - one shouldn't be modifying these since they
can be cached.

-Yonik
http://www.lucidimagination.com