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 Yonghui Zhao <zh...@gmail.com> on 2013/07/29 16:56:29 UTC

getNumericDocValues

In luncene 4.3 AtomicReader  has this interface

  public abstract NumericDocValues getNumericDocValues(String field)
throwsIOException

If I get a NumericDocValues of one field from a reader.

NumericDocValues has  get interface.

/**

   * Returns the numeric value for the specified document ID.

   * @param docID document ID to lookup

   * @return numeric value

   */

  public abstract long get(int docID);

I want to know what will be returned if  the input docID is not a valid id,
for examples:

1. the docID beyonds the reader scope

2. the doc with this docID is already deleted

2. the doc with this docID doesn't has the field

In one word, how can I check if the return value is valid.

Re: getNumericDocValues

Posted by Yonghui Zhao <zh...@gmail.com>.
Got it,  thank you very much.
在 2013-7-29 下午11:34,"Adrien Grand" <jp...@gmail.com>写道:

> Hi,
>
> On Mon, Jul 29, 2013 at 4:56 PM, Yonghui Zhao <zh...@gmail.com>
> wrote:
> > I want to know what will be returned if  the input docID is not a valid
> id,
> > for examples:
> >
> > 1. the docID beyonds the reader scope
>
> In that case, the behavior is not defined, it might throw an exception
> or return a random value. You should make sure you always call this
> method with a valid document ID.
>
> > 2. the doc with this docID is already deleted
>
> It will return the same value it returned prior to the document
> deletion. However, you shouldn't rely on this.
>
> > 2. the doc with this docID doesn't has the field
>
> In that case, the behavior is defined: it will return 0.
>
> Numeric doc values expect are dense: all documents have a value. When
> a document doesn't have a value, 0 will be assigned by default at
> indexing time.
>
> --
> Adrien
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>

Re: getNumericDocValues

Posted by Adrien Grand <jp...@gmail.com>.
Hi,

On Mon, Jul 29, 2013 at 4:56 PM, Yonghui Zhao <zh...@gmail.com> wrote:
> I want to know what will be returned if  the input docID is not a valid id,
> for examples:
>
> 1. the docID beyonds the reader scope

In that case, the behavior is not defined, it might throw an exception
or return a random value. You should make sure you always call this
method with a valid document ID.

> 2. the doc with this docID is already deleted

It will return the same value it returned prior to the document
deletion. However, you shouldn't rely on this.

> 2. the doc with this docID doesn't has the field

In that case, the behavior is defined: it will return 0.

Numeric doc values expect are dense: all documents have a value. When
a document doesn't have a value, 0 will be assigned by default at
indexing time.

-- 
Adrien

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