You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by Daniel Shane <sh...@LEXUM.UMontreal.CA> on 2009/09/11 21:01:23 UTC

NumericRange Field and LuceneUtils?

Is it normal that LuceneUtils.getString(Document document, String 
fieldName) uses document.getField() in the background?

If, for example, you indexed something using the new NumericRange field, 
then you will get a class cast exception in there.

Would it not be better to call getFieldable() instead of getField()?

Daniel Shane

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


Re: NumericRange Field and LuceneUtils?

Posted by Daniel Shane <sh...@LEXUM.UMontreal.CA>.
Sorry for all the confusion, indeed, the LuceneUtils class I was talking 
about is not in the Lucene distro, so I'd like to appologize if I wasted 
anyones time on this... *guilt*.

I'll second Yonik in thinking that maybe getField() is a bit broken 
since it may lead to class cast exceptions, even though the JavaDoc says 
not to use it with lazy loading fields.

Daniel Shane

Uwe Schindler wrote:
>> On Fri, Sep 11, 2009 at 4:45 PM, Uwe Schindler <uw...@thetaphi.de> wrote:
>>     
>>> By the way: This is documented:
>>> http://hudson.zones.apache.org/hudson/job/Lucene-
>>>       
>> trunk/javadoc/core/org/apac
>>     
>>> he/lucene/document/NumericField.html
>>>
>>> NOTE: This class is only used during indexing. When retrieving the
>>>       
>> stored
>>     
>>> field value from a Document instance after search, you will get a
>>> conventional Fieldable instance where the numeric values are returned as
>>> Strings (according to toString(value) of the used data type).
>>>
>>> (this o.a.l.document.Fieldable is always a o.a.l.document.Field)
>>>       
>> Lazy loading could return a different implementation.  Even w/o lazy
>> loading, we're also not going to guarantee that a Fieldable is always
>> a Field, right?  Perhaps those methods returning a Field should be
>> deprecated sometime.
>>     
>
> Yes. But this is not related to NumericField at all. But it would provide us
> the possibility to return also NumericField instances from stored fields
> some time in future.
>
> Uwe
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-dev-help@lucene.apache.org
>
>   


RE: NumericRange Field and LuceneUtils?

Posted by Uwe Schindler <uw...@thetaphi.de>.
> On Fri, Sep 11, 2009 at 4:45 PM, Uwe Schindler <uw...@thetaphi.de> wrote:
> > By the way: This is documented:
> > http://hudson.zones.apache.org/hudson/job/Lucene-
> trunk/javadoc/core/org/apac
> > he/lucene/document/NumericField.html
> >
> > NOTE: This class is only used during indexing. When retrieving the
> stored
> > field value from a Document instance after search, you will get a
> > conventional Fieldable instance where the numeric values are returned as
> > Strings (according to toString(value) of the used data type).
> >
> > (this o.a.l.document.Fieldable is always a o.a.l.document.Field)
> 
> Lazy loading could return a different implementation.  Even w/o lazy
> loading, we're also not going to guarantee that a Fieldable is always
> a Field, right?  Perhaps those methods returning a Field should be
> deprecated sometime.

Yes. But this is not related to NumericField at all. But it would provide us
the possibility to return also NumericField instances from stored fields
some time in future.

Uwe


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


Re: NumericRange Field and LuceneUtils?

Posted by Yonik Seeley <ys...@gmail.com>.
On Fri, Sep 11, 2009 at 4:45 PM, Uwe Schindler <uw...@thetaphi.de> wrote:
> By the way: This is documented:
> http://hudson.zones.apache.org/hudson/job/Lucene-trunk/javadoc/core/org/apac
> he/lucene/document/NumericField.html
>
> NOTE: This class is only used during indexing. When retrieving the stored
> field value from a Document instance after search, you will get a
> conventional Fieldable instance where the numeric values are returned as
> Strings (according to toString(value) of the used data type).
>
> (this o.a.l.document.Fieldable is always a o.a.l.document.Field)

Lazy loading could return a different implementation.  Even w/o lazy
loading, we're also not going to guarantee that a Fieldable is always
a Field, right?  Perhaps those methods returning a Field should be
deprecated sometime.

-Yonik
http://www.lucidimagination.com

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


RE: NumericRange Field and LuceneUtils?

Posted by Uwe Schindler <uw...@thetaphi.de>.
By the way: This is documented:
http://hudson.zones.apache.org/hudson/job/Lucene-trunk/javadoc/core/org/apac
he/lucene/document/NumericField.html

NOTE: This class is only used during indexing. When retrieving the stored
field value from a Document instance after search, you will get a
conventional Fieldable instance where the numeric values are returned as
Strings (according to toString(value) of the used data type).

(this o.a.l.document.Fieldable is always a o.a.l.document.Field)

-----
Uwe Schindler
H.-H.-Meier-Allee 63, D-28213 Bremen
http://www.thetaphi.de
eMail: uwe@thetaphi.de


> -----Original Message-----
> From: Uwe Schindler [mailto:uwe@thetaphi.de]
> Sent: Friday, September 11, 2009 10:38 PM
> To: java-dev@lucene.apache.org
> Subject: RE: NumericRange Field and LuceneUtils?
> 
> Hallo Daniel,
> 
> I am not really sure what you are talking about (what is LuceneUtils?).
> 
> To your question about NumericField: NumericField is only used for
> indexing.
> If you also store the field to retrieve it from the index e.g. with search
> results, NumericField creates a stored Field containing the number as a
> conventional string (the special trie encoding is only used for *indexing*
> not *storing*). If you call getField() it returns a standard Field
> containg
> the number as String.
> 
> -----
> Uwe Schindler
> H.-H.-Meier-Allee 63, D-28213 Bremen
> http://www.thetaphi.de
> eMail: uwe@thetaphi.de
> 
> > -----Original Message-----
> > From: Daniel Shane [mailto:shaned@LEXUM.UMontreal.CA]
> > Sent: Friday, September 11, 2009 9:01 PM
> > To: java-dev@lucene.apache.org
> > Subject: NumericRange Field and LuceneUtils?
> >
> > Is it normal that LuceneUtils.getString(Document document, String
> > fieldName) uses document.getField() in the background?
> >
> > If, for example, you indexed something using the new NumericRange field,
> > then you will get a class cast exception in there.
> >
> > Would it not be better to call getFieldable() instead of getField()?
> >
> > Daniel Shane
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
> > For additional commands, e-mail: java-dev-help@lucene.apache.org
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-dev-help@lucene.apache.org



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


RE: NumericRange Field and LuceneUtils?

Posted by Uwe Schindler <uw...@thetaphi.de>.
Hallo Daniel,

I am not really sure what you are talking about (what is LuceneUtils?).

To your question about NumericField: NumericField is only used for indexing.
If you also store the field to retrieve it from the index e.g. with search
results, NumericField creates a stored Field containing the number as a
conventional string (the special trie encoding is only used for *indexing*
not *storing*). If you call getField() it returns a standard Field containg
the number as String.

-----
Uwe Schindler
H.-H.-Meier-Allee 63, D-28213 Bremen
http://www.thetaphi.de
eMail: uwe@thetaphi.de

> -----Original Message-----
> From: Daniel Shane [mailto:shaned@LEXUM.UMontreal.CA]
> Sent: Friday, September 11, 2009 9:01 PM
> To: java-dev@lucene.apache.org
> Subject: NumericRange Field and LuceneUtils?
> 
> Is it normal that LuceneUtils.getString(Document document, String
> fieldName) uses document.getField() in the background?
> 
> If, for example, you indexed something using the new NumericRange field,
> then you will get a class cast exception in there.
> 
> Would it not be better to call getFieldable() instead of getField()?
> 
> Daniel Shane
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-dev-help@lucene.apache.org



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


Re: NumericRange Field and LuceneUtils?

Posted by Chris Hostetter <ho...@fucit.org>.
: Subject: NumericRange Field and LuceneUtils?
: References: <9a...@mail.gmail.com>
: In-Reply-To: <9a...@mail.gmail.com>

http://people.apache.org/~hossman/#threadhijack
Thread Hijacking on Mailing Lists

When starting a new discussion on a mailing list, please do not reply to 
an existing message, instead start a fresh email.  Even if you change the 
subject line of your email, other mail headers still track which thread 
you replied to and your question is "hidden" in that thread and gets less 
attention.   It makes following discussions in the mailing list archives 
particularly difficult.
See Also:  http://en.wikipedia.org/wiki/Thread_hijacking



-Hoss


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


Re: NumericRange Field and LuceneUtils?

Posted by Yonik Seeley <yo...@lucidimagination.com>.
Sounds right... but this LuceneUtils class isn't part of Lucene is it?

-Yonik
http://www.lucidimagination.com



On Fri, Sep 11, 2009 at 3:01 PM, Daniel Shane <sh...@lexum.umontreal.ca> wrote:
> Is it normal that LuceneUtils.getString(Document document, String fieldName)
> uses document.getField() in the background?
>
> If, for example, you indexed something using the new NumericRange field,
> then you will get a class cast exception in there.
>
> Would it not be better to call getFieldable() instead of getField()?
>
> Daniel Shane

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