You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by ka...@nokia.com on 2010/08/18 16:49:29 UTC

Question about string retrieval with FieldCache in trunk

Hi folks,

What is the proper way to retrieve a string field from lucene in trunk?  I'm specifically looking for the equivalent of:

String[] fieldValues = FieldCache.DEFAULT.getStrings(reader,fieldName);
String actualValue = fieldValues[luceneID-docBase];

The getStrings() method seems to have gone away in FieldCache.java, and it's not clear how to work with ByteRefs to do the equivalent.  Any hints?

Karl




Re: Question about string retrieval with FieldCache in trunk

Posted by Yonik Seeley <yo...@lucidimagination.com>.
On Wed, Aug 18, 2010 at 12:03 PM, Yonik Seeley
<yo...@lucidimagination.com> wrote:
> On Wed, Aug 18, 2010 at 11:28 AM,  <ka...@nokia.com> wrote:
>> If you are correct, the comment is certainly incorrect, since it implies that the SAME BytesRef is returned as you pass in.
>
> Yes, that's correct.  BytesRef is mutable.  You pass in an instance,
> and the value is set and the same BytesRef is normally returned to
> you.  I guess the fact that it's returned at all is to allow a
> flexible implementation to possibly return a BytesRef from somewhere
> else.
>
> So:
>  BytesRef reuse = new BytesRef();
>  for (;;) {
>    BytesRef val = docTerms.getTerm(id, reuse);
>    // use val, but make a copy
>  }

comment got truncated... it should read:
// use val, but make a copy if you need to retain it beyond one loop
iteration (since it will be overwritten)

-Yonik
http://www.lucidimagination.com

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


Re: Question about string retrieval with FieldCache in trunk

Posted by Yonik Seeley <yo...@lucidimagination.com>.
On Wed, Aug 18, 2010 at 11:28 AM,  <ka...@nokia.com> wrote:
> If you are correct, the comment is certainly incorrect, since it implies that the SAME BytesRef is returned as you pass in.

Yes, that's correct.  BytesRef is mutable.  You pass in an instance,
and the value is set and the same BytesRef is normally returned to
you.  I guess the fact that it's returned at all is to allow a
flexible implementation to possibly return a BytesRef from somewhere
else.

So:
  BytesRef reuse = new BytesRef();
  for (;;) {
    BytesRef val = docTerms.getTerm(id, reuse);
    // use val, but make a copy
  }

I think Mike changed the implementation in the past.  We should check
if a BytesRef return value is really needed.

-Yonik
http://www.lucidimagination.com

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


RE: Question about string retrieval with FieldCache in trunk

Posted by ka...@nokia.com.
If you are correct, the comment is certainly incorrect, since it implies that the SAME BytesRef is returned as you pass in.
Karl

-----Original Message-----
From: ext Jason Rutherglen [mailto:jason.rutherglen@gmail.com] 
Sent: Wednesday, August 18, 2010 11:27 AM
To: dev@lucene.apache.org
Cc: yonik@lucidimagination.com
Subject: Re: Question about string retrieval with FieldCache in trunk

Karl,

I believe one may pass an empty BytesRef in, and the values will be
set within the getTerm method.

On Wed, Aug 18, 2010 at 8:18 AM,  <ka...@nokia.com> wrote:
> Exactly. getTerms() returns a DocTerms, which has this:
>
>    /** The BytesRef argument must not be null; the method
>     *  returns the same BytesRef, or an empty (length=0)
>     *  BytesRef if the doc did not have this field or was
>     *  deleted. */
>    public abstract BytesRef getTerm(int docID, BytesRef ret);
>
> How in the blazes do you create the correct BytesRef in the first place?  Or is the comment wrong?
>
> Karl
>
>
> -----Original Message-----
> From: yseeley@gmail.com [mailto:yseeley@gmail.com] On Behalf Of ext Yonik Seeley
> Sent: Wednesday, August 18, 2010 10:55 AM
> To: dev@lucene.apache.org
> Subject: Re: Question about string retrieval with FieldCache in trunk
>
> Check out getTerms and getTermsIndex
>
> -Yonik
> http://www.lucidimagination.com
>
> On Wed, Aug 18, 2010 at 10:49 AM,  <ka...@nokia.com> wrote:
>> Hi folks,
>>
>> What is the proper way to retrieve a string field from lucene in trunk?  I'm
>> specifically looking for the equivalent of:
>>
>> String[] fieldValues = FieldCache.DEFAULT.getStrings(reader,fieldName);
>> String actualValue = fieldValues[luceneID-docBase];
>>
>> The getStrings() method seems to have gone away in FieldCache.java, and it's
>> not clear how to work with ByteRefs to do the equivalent.  Any hints?
>>
>> Karl
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
> For additional commands, e-mail: dev-help@lucene.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
> For additional commands, e-mail: dev-help@lucene.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


RE: Question about string retrieval with FieldCache in trunk

Posted by ka...@nokia.com.
Ah, the old "switch that you shouldn't throw" trick. ;-)
Karl

-----Original Message-----
From: ext Michael McCandless [mailto:lucene@mikemccandless.com] 
Sent: Wednesday, August 18, 2010 2:39 PM
To: dev@lucene.apache.org
Subject: Re: Question about string retrieval with FieldCache in trunk

OK, that's good you got to the bottom of it.

This is (for better or worse) how FieldCache works.  It uninverts the
requested field to reconstruct the "forward" index (mapping docID ->
value), so the field must be indexed (and every field must have a
single token/value).

I agree it's odd... and there's work underway to add index values to
Lucene (called column-stride fields):

    https://issues.apache.org/jira/browse/LUCENE-2186

These would be directly stored in the index in "forward" index form.

Mike

On Wed, Aug 18, 2010 at 2:31 PM,  <ka...@nokia.com> wrote:
> This field was *not* indexed, just stored.  That seems to have been the problem.  Not sure why it must be indexed to be retrievable, but clearly it does.
>
> Karl
>
> -----Original Message-----
> From: ext Michael McCandless [mailto:lucene@mikemccandless.com]
> Sent: Wednesday, August 18, 2010 2:28 PM
> To: dev@lucene.apache.org
> Subject: Re: Question about string retrieval with FieldCache in trunk
>
> Odd... the field is definitely indexed?  If you try getTermsIndex are
> they still empty?
>
> Are you just calling .utf8ToString() to get the String from the BytesRef?
>
> Mike
>
> On Wed, Aug 18, 2010 at 1:18 PM,  <ka...@nokia.com> wrote:
>> Thanks, didn't think to look there.
>>
>> Unfortunately I'm still getting back empty strings - and this is for a required field.  So something isn't right...
>>
>> Maybe I'll pester Simon. ;-)
>> Karl
>>
>> -----Original Message-----
>> From: ext Michael McCandless [mailto:lucene@mikemccandless.com]
>> Sent: Wednesday, August 18, 2010 12:43 PM
>> To: dev@lucene.apache.org
>> Subject: Re: Question about string retrieval with FieldCache in trunk
>>
>> Also note that the MIGRATE.txt in the lucene subdir should cover this.
>>
>> Mike
>>
>> Sent from my iPad
>>
>> On Aug 18, 2010, at 11:26 AM, Jason Rutherglen <ja...@gmail.com> wrote:
>>
>>> Karl,
>>>
>>> I believe one may pass an empty BytesRef in, and the values will be
>>> set within the getTerm method.
>>>
>>> On Wed, Aug 18, 2010 at 8:18 AM,  <ka...@nokia.com> wrote:
>>>> Exactly. getTerms() returns a DocTerms, which has this:
>>>>
>>>>    /** The BytesRef argument must not be null; the method
>>>>     *  returns the same BytesRef, or an empty (length=0)
>>>>     *  BytesRef if the doc did not have this field or was
>>>>     *  deleted. */
>>>>    public abstract BytesRef getTerm(int docID, BytesRef ret);
>>>>
>>>> How in the blazes do you create the correct BytesRef in the first place?  Or is the comment wrong?
>>>>
>>>> Karl
>>>>
>>>>
>>>> -----Original Message-----
>>>> From: yseeley@gmail.com [mailto:yseeley@gmail.com] On Behalf Of ext Yonik Seeley
>>>> Sent: Wednesday, August 18, 2010 10:55 AM
>>>> To: dev@lucene.apache.org
>>>> Subject: Re: Question about string retrieval with FieldCache in trunk
>>>>
>>>> Check out getTerms and getTermsIndex
>>>>
>>>> -Yonik
>>>> http://www.lucidimagination.com
>>>>
>>>> On Wed, Aug 18, 2010 at 10:49 AM,  <ka...@nokia.com> wrote:
>>>>> Hi folks,
>>>>>
>>>>> What is the proper way to retrieve a string field from lucene in trunk?  I'm
>>>>> specifically looking for the equivalent of:
>>>>>
>>>>> String[] fieldValues = FieldCache.DEFAULT.getStrings(reader,fieldName);
>>>>> String actualValue = fieldValues[luceneID-docBase];
>>>>>
>>>>> The getStrings() method seems to have gone away in FieldCache.java, and it's
>>>>> not clear how to work with ByteRefs to do the equivalent.  Any hints?
>>>>>
>>>>> Karl
>>>>>
>>>>>
>>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
>>>> For additional commands, e-mail: dev-help@lucene.apache.org
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
>>>> For additional commands, e-mail: dev-help@lucene.apache.org
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
>>> For additional commands, e-mail: dev-help@lucene.apache.org
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
>> For additional commands, e-mail: dev-help@lucene.apache.org
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
>> For additional commands, e-mail: dev-help@lucene.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
> For additional commands, e-mail: dev-help@lucene.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
> For additional commands, e-mail: dev-help@lucene.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


Re: Question about string retrieval with FieldCache in trunk

Posted by Michael McCandless <lu...@mikemccandless.com>.
OK, that's good you got to the bottom of it.

This is (for better or worse) how FieldCache works.  It uninverts the
requested field to reconstruct the "forward" index (mapping docID ->
value), so the field must be indexed (and every field must have a
single token/value).

I agree it's odd... and there's work underway to add index values to
Lucene (called column-stride fields):

    https://issues.apache.org/jira/browse/LUCENE-2186

These would be directly stored in the index in "forward" index form.

Mike

On Wed, Aug 18, 2010 at 2:31 PM,  <ka...@nokia.com> wrote:
> This field was *not* indexed, just stored.  That seems to have been the problem.  Not sure why it must be indexed to be retrievable, but clearly it does.
>
> Karl
>
> -----Original Message-----
> From: ext Michael McCandless [mailto:lucene@mikemccandless.com]
> Sent: Wednesday, August 18, 2010 2:28 PM
> To: dev@lucene.apache.org
> Subject: Re: Question about string retrieval with FieldCache in trunk
>
> Odd... the field is definitely indexed?  If you try getTermsIndex are
> they still empty?
>
> Are you just calling .utf8ToString() to get the String from the BytesRef?
>
> Mike
>
> On Wed, Aug 18, 2010 at 1:18 PM,  <ka...@nokia.com> wrote:
>> Thanks, didn't think to look there.
>>
>> Unfortunately I'm still getting back empty strings - and this is for a required field.  So something isn't right...
>>
>> Maybe I'll pester Simon. ;-)
>> Karl
>>
>> -----Original Message-----
>> From: ext Michael McCandless [mailto:lucene@mikemccandless.com]
>> Sent: Wednesday, August 18, 2010 12:43 PM
>> To: dev@lucene.apache.org
>> Subject: Re: Question about string retrieval with FieldCache in trunk
>>
>> Also note that the MIGRATE.txt in the lucene subdir should cover this.
>>
>> Mike
>>
>> Sent from my iPad
>>
>> On Aug 18, 2010, at 11:26 AM, Jason Rutherglen <ja...@gmail.com> wrote:
>>
>>> Karl,
>>>
>>> I believe one may pass an empty BytesRef in, and the values will be
>>> set within the getTerm method.
>>>
>>> On Wed, Aug 18, 2010 at 8:18 AM,  <ka...@nokia.com> wrote:
>>>> Exactly. getTerms() returns a DocTerms, which has this:
>>>>
>>>>    /** The BytesRef argument must not be null; the method
>>>>     *  returns the same BytesRef, or an empty (length=0)
>>>>     *  BytesRef if the doc did not have this field or was
>>>>     *  deleted. */
>>>>    public abstract BytesRef getTerm(int docID, BytesRef ret);
>>>>
>>>> How in the blazes do you create the correct BytesRef in the first place?  Or is the comment wrong?
>>>>
>>>> Karl
>>>>
>>>>
>>>> -----Original Message-----
>>>> From: yseeley@gmail.com [mailto:yseeley@gmail.com] On Behalf Of ext Yonik Seeley
>>>> Sent: Wednesday, August 18, 2010 10:55 AM
>>>> To: dev@lucene.apache.org
>>>> Subject: Re: Question about string retrieval with FieldCache in trunk
>>>>
>>>> Check out getTerms and getTermsIndex
>>>>
>>>> -Yonik
>>>> http://www.lucidimagination.com
>>>>
>>>> On Wed, Aug 18, 2010 at 10:49 AM,  <ka...@nokia.com> wrote:
>>>>> Hi folks,
>>>>>
>>>>> What is the proper way to retrieve a string field from lucene in trunk?  I'm
>>>>> specifically looking for the equivalent of:
>>>>>
>>>>> String[] fieldValues = FieldCache.DEFAULT.getStrings(reader,fieldName);
>>>>> String actualValue = fieldValues[luceneID-docBase];
>>>>>
>>>>> The getStrings() method seems to have gone away in FieldCache.java, and it's
>>>>> not clear how to work with ByteRefs to do the equivalent.  Any hints?
>>>>>
>>>>> Karl
>>>>>
>>>>>
>>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
>>>> For additional commands, e-mail: dev-help@lucene.apache.org
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
>>>> For additional commands, e-mail: dev-help@lucene.apache.org
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
>>> For additional commands, e-mail: dev-help@lucene.apache.org
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
>> For additional commands, e-mail: dev-help@lucene.apache.org
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
>> For additional commands, e-mail: dev-help@lucene.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
> For additional commands, e-mail: dev-help@lucene.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
> For additional commands, e-mail: dev-help@lucene.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


RE: Question about string retrieval with FieldCache in trunk

Posted by ka...@nokia.com.
This field was *not* indexed, just stored.  That seems to have been the problem.  Not sure why it must be indexed to be retrievable, but clearly it does.

Karl

-----Original Message-----
From: ext Michael McCandless [mailto:lucene@mikemccandless.com] 
Sent: Wednesday, August 18, 2010 2:28 PM
To: dev@lucene.apache.org
Subject: Re: Question about string retrieval with FieldCache in trunk

Odd... the field is definitely indexed?  If you try getTermsIndex are
they still empty?

Are you just calling .utf8ToString() to get the String from the BytesRef?

Mike

On Wed, Aug 18, 2010 at 1:18 PM,  <ka...@nokia.com> wrote:
> Thanks, didn't think to look there.
>
> Unfortunately I'm still getting back empty strings - and this is for a required field.  So something isn't right...
>
> Maybe I'll pester Simon. ;-)
> Karl
>
> -----Original Message-----
> From: ext Michael McCandless [mailto:lucene@mikemccandless.com]
> Sent: Wednesday, August 18, 2010 12:43 PM
> To: dev@lucene.apache.org
> Subject: Re: Question about string retrieval with FieldCache in trunk
>
> Also note that the MIGRATE.txt in the lucene subdir should cover this.
>
> Mike
>
> Sent from my iPad
>
> On Aug 18, 2010, at 11:26 AM, Jason Rutherglen <ja...@gmail.com> wrote:
>
>> Karl,
>>
>> I believe one may pass an empty BytesRef in, and the values will be
>> set within the getTerm method.
>>
>> On Wed, Aug 18, 2010 at 8:18 AM,  <ka...@nokia.com> wrote:
>>> Exactly. getTerms() returns a DocTerms, which has this:
>>>
>>>    /** The BytesRef argument must not be null; the method
>>>     *  returns the same BytesRef, or an empty (length=0)
>>>     *  BytesRef if the doc did not have this field or was
>>>     *  deleted. */
>>>    public abstract BytesRef getTerm(int docID, BytesRef ret);
>>>
>>> How in the blazes do you create the correct BytesRef in the first place?  Or is the comment wrong?
>>>
>>> Karl
>>>
>>>
>>> -----Original Message-----
>>> From: yseeley@gmail.com [mailto:yseeley@gmail.com] On Behalf Of ext Yonik Seeley
>>> Sent: Wednesday, August 18, 2010 10:55 AM
>>> To: dev@lucene.apache.org
>>> Subject: Re: Question about string retrieval with FieldCache in trunk
>>>
>>> Check out getTerms and getTermsIndex
>>>
>>> -Yonik
>>> http://www.lucidimagination.com
>>>
>>> On Wed, Aug 18, 2010 at 10:49 AM,  <ka...@nokia.com> wrote:
>>>> Hi folks,
>>>>
>>>> What is the proper way to retrieve a string field from lucene in trunk?  I'm
>>>> specifically looking for the equivalent of:
>>>>
>>>> String[] fieldValues = FieldCache.DEFAULT.getStrings(reader,fieldName);
>>>> String actualValue = fieldValues[luceneID-docBase];
>>>>
>>>> The getStrings() method seems to have gone away in FieldCache.java, and it's
>>>> not clear how to work with ByteRefs to do the equivalent.  Any hints?
>>>>
>>>> Karl
>>>>
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
>>> For additional commands, e-mail: dev-help@lucene.apache.org
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
>>> For additional commands, e-mail: dev-help@lucene.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
>> For additional commands, e-mail: dev-help@lucene.apache.org
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
> For additional commands, e-mail: dev-help@lucene.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
> For additional commands, e-mail: dev-help@lucene.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


Re: Question about string retrieval with FieldCache in trunk

Posted by Michael McCandless <lu...@mikemccandless.com>.
Odd... the field is definitely indexed?  If you try getTermsIndex are
they still empty?

Are you just calling .utf8ToString() to get the String from the BytesRef?

Mike

On Wed, Aug 18, 2010 at 1:18 PM,  <ka...@nokia.com> wrote:
> Thanks, didn't think to look there.
>
> Unfortunately I'm still getting back empty strings - and this is for a required field.  So something isn't right...
>
> Maybe I'll pester Simon. ;-)
> Karl
>
> -----Original Message-----
> From: ext Michael McCandless [mailto:lucene@mikemccandless.com]
> Sent: Wednesday, August 18, 2010 12:43 PM
> To: dev@lucene.apache.org
> Subject: Re: Question about string retrieval with FieldCache in trunk
>
> Also note that the MIGRATE.txt in the lucene subdir should cover this.
>
> Mike
>
> Sent from my iPad
>
> On Aug 18, 2010, at 11:26 AM, Jason Rutherglen <ja...@gmail.com> wrote:
>
>> Karl,
>>
>> I believe one may pass an empty BytesRef in, and the values will be
>> set within the getTerm method.
>>
>> On Wed, Aug 18, 2010 at 8:18 AM,  <ka...@nokia.com> wrote:
>>> Exactly. getTerms() returns a DocTerms, which has this:
>>>
>>>    /** The BytesRef argument must not be null; the method
>>>     *  returns the same BytesRef, or an empty (length=0)
>>>     *  BytesRef if the doc did not have this field or was
>>>     *  deleted. */
>>>    public abstract BytesRef getTerm(int docID, BytesRef ret);
>>>
>>> How in the blazes do you create the correct BytesRef in the first place?  Or is the comment wrong?
>>>
>>> Karl
>>>
>>>
>>> -----Original Message-----
>>> From: yseeley@gmail.com [mailto:yseeley@gmail.com] On Behalf Of ext Yonik Seeley
>>> Sent: Wednesday, August 18, 2010 10:55 AM
>>> To: dev@lucene.apache.org
>>> Subject: Re: Question about string retrieval with FieldCache in trunk
>>>
>>> Check out getTerms and getTermsIndex
>>>
>>> -Yonik
>>> http://www.lucidimagination.com
>>>
>>> On Wed, Aug 18, 2010 at 10:49 AM,  <ka...@nokia.com> wrote:
>>>> Hi folks,
>>>>
>>>> What is the proper way to retrieve a string field from lucene in trunk?  I'm
>>>> specifically looking for the equivalent of:
>>>>
>>>> String[] fieldValues = FieldCache.DEFAULT.getStrings(reader,fieldName);
>>>> String actualValue = fieldValues[luceneID-docBase];
>>>>
>>>> The getStrings() method seems to have gone away in FieldCache.java, and it's
>>>> not clear how to work with ByteRefs to do the equivalent.  Any hints?
>>>>
>>>> Karl
>>>>
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
>>> For additional commands, e-mail: dev-help@lucene.apache.org
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
>>> For additional commands, e-mail: dev-help@lucene.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
>> For additional commands, e-mail: dev-help@lucene.apache.org
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
> For additional commands, e-mail: dev-help@lucene.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
> For additional commands, e-mail: dev-help@lucene.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


RE: Question about string retrieval with FieldCache in trunk

Posted by ka...@nokia.com.
Thanks, didn't think to look there.

Unfortunately I'm still getting back empty strings - and this is for a required field.  So something isn't right...

Maybe I'll pester Simon. ;-)
Karl

-----Original Message-----
From: ext Michael McCandless [mailto:lucene@mikemccandless.com] 
Sent: Wednesday, August 18, 2010 12:43 PM
To: dev@lucene.apache.org
Subject: Re: Question about string retrieval with FieldCache in trunk

Also note that the MIGRATE.txt in the lucene subdir should cover this.

Mike

Sent from my iPad

On Aug 18, 2010, at 11:26 AM, Jason Rutherglen <ja...@gmail.com> wrote:

> Karl,
> 
> I believe one may pass an empty BytesRef in, and the values will be
> set within the getTerm method.
> 
> On Wed, Aug 18, 2010 at 8:18 AM,  <ka...@nokia.com> wrote:
>> Exactly. getTerms() returns a DocTerms, which has this:
>> 
>>    /** The BytesRef argument must not be null; the method
>>     *  returns the same BytesRef, or an empty (length=0)
>>     *  BytesRef if the doc did not have this field or was
>>     *  deleted. */
>>    public abstract BytesRef getTerm(int docID, BytesRef ret);
>> 
>> How in the blazes do you create the correct BytesRef in the first place?  Or is the comment wrong?
>> 
>> Karl
>> 
>> 
>> -----Original Message-----
>> From: yseeley@gmail.com [mailto:yseeley@gmail.com] On Behalf Of ext Yonik Seeley
>> Sent: Wednesday, August 18, 2010 10:55 AM
>> To: dev@lucene.apache.org
>> Subject: Re: Question about string retrieval with FieldCache in trunk
>> 
>> Check out getTerms and getTermsIndex
>> 
>> -Yonik
>> http://www.lucidimagination.com
>> 
>> On Wed, Aug 18, 2010 at 10:49 AM,  <ka...@nokia.com> wrote:
>>> Hi folks,
>>> 
>>> What is the proper way to retrieve a string field from lucene in trunk?  I'm
>>> specifically looking for the equivalent of:
>>> 
>>> String[] fieldValues = FieldCache.DEFAULT.getStrings(reader,fieldName);
>>> String actualValue = fieldValues[luceneID-docBase];
>>> 
>>> The getStrings() method seems to have gone away in FieldCache.java, and it's
>>> not clear how to work with ByteRefs to do the equivalent.  Any hints?
>>> 
>>> Karl
>>> 
>>> 
>>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
>> For additional commands, e-mail: dev-help@lucene.apache.org
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
>> For additional commands, e-mail: dev-help@lucene.apache.org
>> 
>> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
> For additional commands, e-mail: dev-help@lucene.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


Re: Question about string retrieval with FieldCache in trunk

Posted by Michael McCandless <lu...@mikemccandless.com>.
Also note that the MIGRATE.txt in the lucene subdir should cover this.

Mike

Sent from my iPad

On Aug 18, 2010, at 11:26 AM, Jason Rutherglen <ja...@gmail.com> wrote:

> Karl,
> 
> I believe one may pass an empty BytesRef in, and the values will be
> set within the getTerm method.
> 
> On Wed, Aug 18, 2010 at 8:18 AM,  <ka...@nokia.com> wrote:
>> Exactly. getTerms() returns a DocTerms, which has this:
>> 
>>    /** The BytesRef argument must not be null; the method
>>     *  returns the same BytesRef, or an empty (length=0)
>>     *  BytesRef if the doc did not have this field or was
>>     *  deleted. */
>>    public abstract BytesRef getTerm(int docID, BytesRef ret);
>> 
>> How in the blazes do you create the correct BytesRef in the first place?  Or is the comment wrong?
>> 
>> Karl
>> 
>> 
>> -----Original Message-----
>> From: yseeley@gmail.com [mailto:yseeley@gmail.com] On Behalf Of ext Yonik Seeley
>> Sent: Wednesday, August 18, 2010 10:55 AM
>> To: dev@lucene.apache.org
>> Subject: Re: Question about string retrieval with FieldCache in trunk
>> 
>> Check out getTerms and getTermsIndex
>> 
>> -Yonik
>> http://www.lucidimagination.com
>> 
>> On Wed, Aug 18, 2010 at 10:49 AM,  <ka...@nokia.com> wrote:
>>> Hi folks,
>>> 
>>> What is the proper way to retrieve a string field from lucene in trunk?  I'm
>>> specifically looking for the equivalent of:
>>> 
>>> String[] fieldValues = FieldCache.DEFAULT.getStrings(reader,fieldName);
>>> String actualValue = fieldValues[luceneID-docBase];
>>> 
>>> The getStrings() method seems to have gone away in FieldCache.java, and it's
>>> not clear how to work with ByteRefs to do the equivalent.  Any hints?
>>> 
>>> Karl
>>> 
>>> 
>>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
>> For additional commands, e-mail: dev-help@lucene.apache.org
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
>> For additional commands, e-mail: dev-help@lucene.apache.org
>> 
>> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
> For additional commands, e-mail: dev-help@lucene.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


RE: Question about string retrieval with FieldCache in trunk

Posted by ka...@nokia.com.
Passing in new BytesRef(), I always get back an empty string.  So clearly the comment *is* correct, and neither you nor I know how to do this properly. ;-)

Any other suggestions?

Karl

-----Original Message-----
From: Wright Karl (Nokia-MS/Cambridge) 
Sent: Wednesday, August 18, 2010 11:28 AM
To: 'dev@lucene.apache.org'
Subject: RE: Question about string retrieval with FieldCache in trunk

If you are correct, the comment is certainly incorrect, since it implies that the SAME BytesRef is returned as you pass in.
Karl

-----Original Message-----
From: ext Jason Rutherglen [mailto:jason.rutherglen@gmail.com] 
Sent: Wednesday, August 18, 2010 11:27 AM
To: dev@lucene.apache.org
Cc: yonik@lucidimagination.com
Subject: Re: Question about string retrieval with FieldCache in trunk

Karl,

I believe one may pass an empty BytesRef in, and the values will be
set within the getTerm method.

On Wed, Aug 18, 2010 at 8:18 AM,  <ka...@nokia.com> wrote:
> Exactly. getTerms() returns a DocTerms, which has this:
>
>    /** The BytesRef argument must not be null; the method
>     *  returns the same BytesRef, or an empty (length=0)
>     *  BytesRef if the doc did not have this field or was
>     *  deleted. */
>    public abstract BytesRef getTerm(int docID, BytesRef ret);
>
> How in the blazes do you create the correct BytesRef in the first place?  Or is the comment wrong?
>
> Karl
>
>
> -----Original Message-----
> From: yseeley@gmail.com [mailto:yseeley@gmail.com] On Behalf Of ext Yonik Seeley
> Sent: Wednesday, August 18, 2010 10:55 AM
> To: dev@lucene.apache.org
> Subject: Re: Question about string retrieval with FieldCache in trunk
>
> Check out getTerms and getTermsIndex
>
> -Yonik
> http://www.lucidimagination.com
>
> On Wed, Aug 18, 2010 at 10:49 AM,  <ka...@nokia.com> wrote:
>> Hi folks,
>>
>> What is the proper way to retrieve a string field from lucene in trunk?  I'm
>> specifically looking for the equivalent of:
>>
>> String[] fieldValues = FieldCache.DEFAULT.getStrings(reader,fieldName);
>> String actualValue = fieldValues[luceneID-docBase];
>>
>> The getStrings() method seems to have gone away in FieldCache.java, and it's
>> not clear how to work with ByteRefs to do the equivalent.  Any hints?
>>
>> Karl
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
> For additional commands, e-mail: dev-help@lucene.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
> For additional commands, e-mail: dev-help@lucene.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


Re: Question about string retrieval with FieldCache in trunk

Posted by Jason Rutherglen <ja...@gmail.com>.
Karl,

I believe one may pass an empty BytesRef in, and the values will be
set within the getTerm method.

On Wed, Aug 18, 2010 at 8:18 AM,  <ka...@nokia.com> wrote:
> Exactly. getTerms() returns a DocTerms, which has this:
>
>    /** The BytesRef argument must not be null; the method
>     *  returns the same BytesRef, or an empty (length=0)
>     *  BytesRef if the doc did not have this field or was
>     *  deleted. */
>    public abstract BytesRef getTerm(int docID, BytesRef ret);
>
> How in the blazes do you create the correct BytesRef in the first place?  Or is the comment wrong?
>
> Karl
>
>
> -----Original Message-----
> From: yseeley@gmail.com [mailto:yseeley@gmail.com] On Behalf Of ext Yonik Seeley
> Sent: Wednesday, August 18, 2010 10:55 AM
> To: dev@lucene.apache.org
> Subject: Re: Question about string retrieval with FieldCache in trunk
>
> Check out getTerms and getTermsIndex
>
> -Yonik
> http://www.lucidimagination.com
>
> On Wed, Aug 18, 2010 at 10:49 AM,  <ka...@nokia.com> wrote:
>> Hi folks,
>>
>> What is the proper way to retrieve a string field from lucene in trunk?  I'm
>> specifically looking for the equivalent of:
>>
>> String[] fieldValues = FieldCache.DEFAULT.getStrings(reader,fieldName);
>> String actualValue = fieldValues[luceneID-docBase];
>>
>> The getStrings() method seems to have gone away in FieldCache.java, and it's
>> not clear how to work with ByteRefs to do the equivalent.  Any hints?
>>
>> Karl
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
> For additional commands, e-mail: dev-help@lucene.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
> For additional commands, e-mail: dev-help@lucene.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


RE: Question about string retrieval with FieldCache in trunk

Posted by ka...@nokia.com.
Exactly. getTerms() returns a DocTerms, which has this:

    /** The BytesRef argument must not be null; the method
     *  returns the same BytesRef, or an empty (length=0)
     *  BytesRef if the doc did not have this field or was
     *  deleted. */
    public abstract BytesRef getTerm(int docID, BytesRef ret);

How in the blazes do you create the correct BytesRef in the first place?  Or is the comment wrong?

Karl


-----Original Message-----
From: yseeley@gmail.com [mailto:yseeley@gmail.com] On Behalf Of ext Yonik Seeley
Sent: Wednesday, August 18, 2010 10:55 AM
To: dev@lucene.apache.org
Subject: Re: Question about string retrieval with FieldCache in trunk

Check out getTerms and getTermsIndex

-Yonik
http://www.lucidimagination.com

On Wed, Aug 18, 2010 at 10:49 AM,  <ka...@nokia.com> wrote:
> Hi folks,
>
> What is the proper way to retrieve a string field from lucene in trunk?  I'm
> specifically looking for the equivalent of:
>
> String[] fieldValues = FieldCache.DEFAULT.getStrings(reader,fieldName);
> String actualValue = fieldValues[luceneID-docBase];
>
> The getStrings() method seems to have gone away in FieldCache.java, and it's
> not clear how to work with ByteRefs to do the equivalent.  Any hints?
>
> Karl
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


Re: Question about string retrieval with FieldCache in trunk

Posted by Yonik Seeley <yo...@lucidimagination.com>.
Check out getTerms and getTermsIndex

-Yonik
http://www.lucidimagination.com

On Wed, Aug 18, 2010 at 10:49 AM,  <ka...@nokia.com> wrote:
> Hi folks,
>
> What is the proper way to retrieve a string field from lucene in trunk?  I’m
> specifically looking for the equivalent of:
>
> String[] fieldValues = FieldCache.DEFAULT.getStrings(reader,fieldName);
> String actualValue = fieldValues[luceneID-docBase];
>
> The getStrings() method seems to have gone away in FieldCache.java, and it’s
> not clear how to work with ByteRefs to do the equivalent.  Any hints?
>
> Karl
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org