I'm trying to upgrade my custom post filter from Solr 4.9 to 5.2. This filter
collapses documents based on a user chosen field set. The key to the whole
thing is determining document uniqueness based on a fixed int array of field
value ordinals. In 4.9 this worked regardless of the field type. In the
collect() method of my delegating collector:

for (SortedDocValues vals : values) {
   ords[i++] = vals.getOrd(globalDoc);
}

The values come from FieldCache:

SortedDocValues docValues =
FieldCache.DEFAULT.getTermsIndex(searcher.getAtomicReader(), field);

I was not indexing using doc values. Now I'm trying to use doc values, and I
find that for non string fields I can't recover the ordinal for a field
value. At least I don't know how to get at it. So in my upgrade I index with
doc values, and the above code looks like:

SortedDocValues docValues =
searcher.getLeafReader().getSortedDocValues(field);

However this is not equivalent to the old 4.9 approach. My TrieDateField and
TrieDoubleField fields are being ignored (all field value ordinals are
treated as the same). I'm sure there is a good reason why SortedDocValues
exposes the backing dictionary and [Sorted]NumericDocValues does not. How do
I get to the ordinal for number and date fields?

I assume my fallback is to not index with doc values, and use an uninverting
reader to get the field data. Is there a better approach?



--
View this message in context: 
http://lucene.472066.n3.nabble.com/How-to-find-the-ordinal-for-a-numeric-doc-value-tp4224018.html
Sent from the Solr - User mailing list archive at Nabble.com.

Reply via email to