I don't believe I have it working, but have made progress I believe the issue was I was using a SortField() instead of a SortedNumericSortField()
-Todd -----Original Message----- From: Fielder, Todd Patrick [mailto:tpfi...@sandia.gov] Sent: Monday, October 31, 2016 1:46 PM To: java-user@lucene.apache.org Subject: RE: [EXTERNAL] Re: Multivalued DocValuesField I tried your suggestion and was able to get the indexing to work (I assume it's correct), but now the search is throwing an error... unexpected docvalues type SORTED_NUMERIC for field 'Planned Completion Date' (expected=NUMERIC). Use UninvertingReader or index with docvalues. My search code: topDocs = FacetsCollector.search(searcher, q, null, MAX_HITS, new Sort(new SortField("plannedCompletionDate", SortField.Type.LONG, !sc.isAscending())), false, false, fc); My index code: //copied from http://stackoverflow.com/questions/31451111/lucene-5-sort-problems-uninvertedreader-and-docvalues public static final FieldType LONG_FIELD_TYPE_STORED_SORTED = new FieldType(LongField.TYPE_STORED); static { LONG_FIELD_TYPE_STORED_SORTED.setDocValuesType(DocValuesType.SORTED_NUMERIC); LONG_FIELD_TYPE_STORED_SORTED.freeze(); } doc.add(new LongField(field.toString(), time,LONG_FIELD_TYPE_STORED_SORTED)); doc.add(new SortedNumericDocValuesField(field.toString(), time)); Any ideas? Thanks in advance -Todd -----Original Message----- From: Alan Woodward [mailto:a...@flax.co.uk] Sent: Monday, October 31, 2016 10:02 AM To: java-user@lucene.apache.org Subject: [EXTERNAL] Re: Multivalued DocValuesField You need to use a SortedNumericDocValuesField, which allows for multiple numeric values to be stored per-document. I’m not sure if that’s in Lucene 5.0, though, you may need to upgrade to something more recent. Alan Woodward www.flax.co.uk > On 31 Oct 2016, at 15:34, Fielder, Todd Patrick <tpfi...@sandia.gov> wrote: > > Hello, > > I have a question about Multivalued DocValuesFields...I am using > Lucene 5.0 > > I am indexing an object that contains an Array of Sub-objects. Those > sub-objects have a Long value that I need to index with fieldStore=true. > That works just fine. > > I also want to sort that field and so I am attempting to also index it > as a NumericDocValues field. I am using the statement below to > accomplish that doc.add(new NumericDocValuesField(field.toString(), > time)); > > However, since the field occurs multiple times, I am receiving the below > error: > DocValuesField "plannedCompletionDate" appears more than once in this > document (only one value is allowed per field) > > I have tried to set the value to multivalued on the FacetsConfig, but > that doesn't work (it works for multi-valued statements in facets, but > not NumericDocValueFields) > getConfig().setMultiValued("plannedCompletionDate", true); > //getConfig() returns type FacetsConfig() > > > Any ideas how to accomplish this? > Thanks in advance > -Todd