Hi all.

We had been going for the longest time abusing Lucene's doc IDs as our
own IDs and of course all our filters still work like this. But at the
moment, we're looking at ways to break our dependencies on this.

One of the motivators for this is the outright removal of FieldCache
in Lucene 5. (Yes, I see it's there, being used by UninvertingReader,
but even UninvertingReader won't let us use the custom parsers we were
previously relying on to parse values in older fields.)

I know we now have this:

    public void updateNumericDocValue(Term term, String field, long value)
        throws IOException

So to add an ID field, I would have to already have an ID field. :(

Since Lucene is now (more or less?) using a separate index per field,
maybe there is a way to directly add this field?

I don't know if this is down the right path, but it seems like it
would be something like...

try (Directory directory = FSDirectory.open(Paths.get("/Data/BreakMe")))
{
    SegmentInfo segmentInfo = ???;
    FieldInfos fieldInfos = ???;

    SegmentWriteState writeState = new SegmentWriteState(null, directory,
                                                         segmentInfo,
fieldInfos,
                                                         null,
IOContext.DEFAULT);

    try (DocValuesConsumer consumer =
             new Lucene50DocValuesFormat().fieldsConsumer(writeState))
    {
        int number = ???;
        long dvGen = ???;
        Map<String, String> attributes = ???;

        FieldInfo field = new FieldInfo("docid", number, false, true, false,
                                        IndexOptions.DOCS,
DocValuesType.NUMERIC,
                                        dvGen, attributes);
        Iterable<Number> values = () -> IntStream.range(0, 500)
                                                 .mapToObj(i -> (Number) i)
                                                 .iterator();
        consumer.addNumericField(field, values);
    }
}

But there are a *lot* of values that I wouldn't have any idea how to get.

TX

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

Reply via email to