LeafReader.get*Values is a low-level API whose return value depends on what you indexed: if you did not add doc values to your documents then it will return null. This is similar to Fields.terms which returns null if you did not index a field.
On the other hand, DocValues.get* is higher-level and makes consuming doc values easier. In that particular case, it just saves a null check but there are more useful methods like DocValues.getSortedSet which allow to treat fields which have been indexed with DocValuesType.SORTED and DocValuesType.SORTED_SET the same way. On Thu, Jul 9, 2015 at 1:04 PM, Varun Thacker <varunthacker1...@gmail.com> wrote: > Currently we have two APIs for getting DocValues for a field - > > 1. DocValues.getSorted(r, "bogus") > 2. r.getSortedSetDocValues("bogus"); > > Both the javadocs clearly state that 1 will return an empty set and 2 will > return null if no values for the field are present in an segment. > > Was curious as to why do we have two different ways to fetch it and why do > they have an different behaviour on no values for the field are present in > an segment. > > -- > > > Regards, > Varun Thacker -- Adrien --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org For additional commands, e-mail: java-user-h...@lucene.apache.org