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 Kumaran Ramasubramanian <ku...@gmail.com> on 2016/06/01 19:15:13 UTC

Difference in Retrieving values of a docvalue field using atomicreader over duplicate StoredField

Hi All,


In javadoc of every docvalue field
<https://lucene.apache.org/core/4_10_4/core/org/apache/lucene/document/SortedNumericDocValuesField.html>,
there is line like

​
> If you also need to store the value, you should add a separate StoredField
> <https://lucene.apache.org/core/4_10_4/core/org/apache/lucene/document/StoredField.html>
>  instance.​


https://lucene.apache.org/core/4_10_4/core/org/apache/lucene/document/SortedNumericDocValuesField.html




But, we are able to retrieve the value of SortedNumericDocValuesField
using AtomicReader also

for (AtomicReaderContext context : indexReader.leaves())
> {
>  AtomicReader atomicReader = context.reader();
>  SortedNumericDocValues
>  sortedDocValues=DocValues.getSortedNumeric(atomicReader, "Numeric
> ​_docvalue​
> _price");
> }


​So what is the difference actually? Is there any performance or time taken
issue in retrieving values of a docvalue field using atomicreader over
StoredField? ​

Please clarify me what am i missing?​

Thanks in advance


​--​

Kumaran R

Re: Difference in Retrieving values of a docvalue field using atomicreader over duplicate StoredField

Posted by Michael McCandless <lu...@mikemccandless.com>.
You're welcome!

Mike McCandless

http://blog.mikemccandless.com

On Fri, Jun 3, 2016 at 10:20 AM, Kumaran Ramasubramanian <kums.134@gmail.com
> wrote:

> Thanks a lot for the clarification mike :-)
>
>
>
> --
> *​*​
> Kumaran R
>
>
>
>
> On Thu, Jun 2, 2016 at 2:38 AM, Michael McCandless <
> lucene@mikemccandless.com> wrote:
>
> > Well, each access may involve disk seeks (if the pages are not already
> hot
> > in the OS's IO cache).
> >
> > So if you do some doc values + some stored fields you're looking at
> > multiple seeks per docID you retrieve.
> >
> > Really you should only do this for a few hits, e.g. one page worth.
> >
> > Mike McCandless
> >
> > http://blog.mikemccandless.com
> >
> > On Wed, Jun 1, 2016 at 3:15 PM, Kumaran Ramasubramanian <
> > kums.134@gmail.com>
> > wrote:
> >
> > > Hi All,
> > >
> > >
> > > In javadoc of every docvalue field
> > > <
> > >
> >
> https://lucene.apache.org/core/4_10_4/core/org/apache/lucene/document/SortedNumericDocValuesField.html
> > > >,
> > > there is line like
> > >
> > > ​
> > > > If you also need to store the value, you should add a separate
> > > StoredField
> > > > <
> > >
> >
> https://lucene.apache.org/core/4_10_4/core/org/apache/lucene/document/StoredField.html
> > > >
> > > >  instance.​
> > >
> > >
> > >
> > >
> >
> https://lucene.apache.org/core/4_10_4/core/org/apache/lucene/document/SortedNumericDocValuesField.html
> > >
> > >
> > >
> > >
> > > But, we are able to retrieve the value of SortedNumericDocValuesField
> > > using AtomicReader also
> > >
> > > for (AtomicReaderContext context : indexReader.leaves())
> > > > {
> > > >  AtomicReader atomicReader = context.reader();
> > > >  SortedNumericDocValues
> > > >  sortedDocValues=DocValues.getSortedNumeric(atomicReader, "Numeric
> > > > ​_docvalue​
> > > > _price");
> > > > }
> > >
> > >
> > > ​So what is the difference actually? Is there any performance or time
> > taken
> > > issue in retrieving values of a docvalue field using atomicreader over
> > > StoredField? ​
> > >
> > > Please clarify me what am i missing?​
> > >
> > > Thanks in advance
> > >
> > >
> > > ​--​
> > >
> > > Kumaran R
> > >
> >
>

Re: Difference in Retrieving values of a docvalue field using atomicreader over duplicate StoredField

Posted by Kumaran Ramasubramanian <ku...@gmail.com>.
Thanks a lot for the clarification mike :-)



--
*​*​
Kumaran R




On Thu, Jun 2, 2016 at 2:38 AM, Michael McCandless <
lucene@mikemccandless.com> wrote:

> Well, each access may involve disk seeks (if the pages are not already hot
> in the OS's IO cache).
>
> So if you do some doc values + some stored fields you're looking at
> multiple seeks per docID you retrieve.
>
> Really you should only do this for a few hits, e.g. one page worth.
>
> Mike McCandless
>
> http://blog.mikemccandless.com
>
> On Wed, Jun 1, 2016 at 3:15 PM, Kumaran Ramasubramanian <
> kums.134@gmail.com>
> wrote:
>
> > Hi All,
> >
> >
> > In javadoc of every docvalue field
> > <
> >
> https://lucene.apache.org/core/4_10_4/core/org/apache/lucene/document/SortedNumericDocValuesField.html
> > >,
> > there is line like
> >
> > ​
> > > If you also need to store the value, you should add a separate
> > StoredField
> > > <
> >
> https://lucene.apache.org/core/4_10_4/core/org/apache/lucene/document/StoredField.html
> > >
> > >  instance.​
> >
> >
> >
> >
> https://lucene.apache.org/core/4_10_4/core/org/apache/lucene/document/SortedNumericDocValuesField.html
> >
> >
> >
> >
> > But, we are able to retrieve the value of SortedNumericDocValuesField
> > using AtomicReader also
> >
> > for (AtomicReaderContext context : indexReader.leaves())
> > > {
> > >  AtomicReader atomicReader = context.reader();
> > >  SortedNumericDocValues
> > >  sortedDocValues=DocValues.getSortedNumeric(atomicReader, "Numeric
> > > ​_docvalue​
> > > _price");
> > > }
> >
> >
> > ​So what is the difference actually? Is there any performance or time
> taken
> > issue in retrieving values of a docvalue field using atomicreader over
> > StoredField? ​
> >
> > Please clarify me what am i missing?​
> >
> > Thanks in advance
> >
> >
> > ​--​
> >
> > Kumaran R
> >
>

Re: Difference in Retrieving values of a docvalue field using atomicreader over duplicate StoredField

Posted by Michael McCandless <lu...@mikemccandless.com>.
Well, each access may involve disk seeks (if the pages are not already hot
in the OS's IO cache).

So if you do some doc values + some stored fields you're looking at
multiple seeks per docID you retrieve.

Really you should only do this for a few hits, e.g. one page worth.

Mike McCandless

http://blog.mikemccandless.com

On Wed, Jun 1, 2016 at 3:15 PM, Kumaran Ramasubramanian <ku...@gmail.com>
wrote:

> Hi All,
>
>
> In javadoc of every docvalue field
> <
> https://lucene.apache.org/core/4_10_4/core/org/apache/lucene/document/SortedNumericDocValuesField.html
> >,
> there is line like
>
> ​
> > If you also need to store the value, you should add a separate
> StoredField
> > <
> https://lucene.apache.org/core/4_10_4/core/org/apache/lucene/document/StoredField.html
> >
> >  instance.​
>
>
>
> https://lucene.apache.org/core/4_10_4/core/org/apache/lucene/document/SortedNumericDocValuesField.html
>
>
>
>
> But, we are able to retrieve the value of SortedNumericDocValuesField
> using AtomicReader also
>
> for (AtomicReaderContext context : indexReader.leaves())
> > {
> >  AtomicReader atomicReader = context.reader();
> >  SortedNumericDocValues
> >  sortedDocValues=DocValues.getSortedNumeric(atomicReader, "Numeric
> > ​_docvalue​
> > _price");
> > }
>
>
> ​So what is the difference actually? Is there any performance or time taken
> issue in retrieving values of a docvalue field using atomicreader over
> StoredField? ​
>
> Please clarify me what am i missing?​
>
> Thanks in advance
>
>
> ​--​
>
> Kumaran R
>