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 Clemens Wyss DEV <cl...@mysign.ch> on 2015/02/19 13:22:34 UTC

Indexing an IntField but getting SotredField from found Document

When I index a Document with an IntField and then find that very Document the former IntField is returned as StoredField. How do I determine the "original" fieldtype (IntField, LongField, DoubleField ...)?

Must I ?
Number number = Field.numericValue();
if( number != null )
{
  if( number instanceof Integer)
  {
    ...
  }
  else if( number instanceof Double)
  {
    ...
  }
  ....
}

AW: Indexing an IntField but getting SotredField from found Document

Posted by Clemens Wyss DEV <cl...@mysign.ch>.
> I think if you follow the Field.fieldType().numericType() chain you'll 
>end up with INT or DOUBLE or whatever.
Thx!

> But if you know you stored it as an IntField then surely you 
>already know it's an integer? 
True, but the nature of the dynamic framework we build around Lucene requires the lookup in Document/Fields we get from the search. OTH (as we put the type "into" the fieldname) I could lookup the type from the fieldname.

> Unless you sometimes store different things in the one field.  
>I wouldn't do that.
Neither would I, even in a dynamic framework ;)

-----Ursprüngliche Nachricht-----
Von: Ian Lea [mailto:ian.lea@gmail.com] 
Gesendet: Donnerstag, 19. Februar 2015 16:16
An: java-user@lucene.apache.org
Betreff: Re: Indexing an IntField but getting SotredField from found Document

I think if you follow the Field.fieldType().numericType() chain you'll end up with INT or DOUBLE or whatever.

But if you know you stored it as an IntField then surely you already know it's an integer?  Unless you sometimes store different things in the one field.  I wouldn't do that.


--
Ian.


On Thu, Feb 19, 2015 at 12:22 PM, Clemens Wyss DEV <cl...@mysign.ch> wrote:
> When I index a Document with an IntField and then find that very Document the former IntField is returned as StoredField. How do I determine the "original" fieldtype (IntField, LongField, DoubleField ...)?
>
> Must I ?
> Number number = Field.numericValue();
> if( number != null )
> {
>   if( number instanceof Integer)
>   {
>     ...
>   }
>   else if( number instanceof Double)
>   {
>     ...
>   }
>   ....
> }

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


Re: Indexing an IntField but getting SotredField from found Document

Posted by Ian Lea <ia...@gmail.com>.
I think if you follow the Field.fieldType().numericType() chain you'll
end up with INT or DOUBLE or whatever.

But if you know you stored it as an IntField then surely you already
know it's an integer?  Unless you sometimes store different things in
the one field.  I wouldn't do that.


--
Ian.


On Thu, Feb 19, 2015 at 12:22 PM, Clemens Wyss DEV <cl...@mysign.ch> wrote:
> When I index a Document with an IntField and then find that very Document the former IntField is returned as StoredField. How do I determine the "original" fieldtype (IntField, LongField, DoubleField ...)?
>
> Must I ?
> Number number = Field.numericValue();
> if( number != null )
> {
>   if( number instanceof Integer)
>   {
>     ...
>   }
>   else if( number instanceof Double)
>   {
>     ...
>   }
>   ....
> }

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