Hi Paul,

On Wed, Mar 27, 2013 at 1:58 PM, Paul Bell <arach...@gmail.com> wrote:
> As to the ideas raised in the links you pointed me to: the first link shows
> the instantiation of a Term object via
>
>    writer.UpdateDocument(new Term("IDField", *id*), doc);
>
> yet in the 4.2.0 docs I see no Term constructor that allows this "id"
> field.

I think this is this one:
http://lucene.apache.org/core/4_2_0/core/org/apache/lucene/index/Term.html#Term(java.lang.String,
java.lang.String)

> But this raises an interesting question: is it possible to tell Lucene that
> the Document I've given it to index has a specific identifier? Here's an
> example of what I mean. Suppose that the DB in question is a NoSQL type of
> the graph flavor. I add a vertex to that graph. The vertex contains some
> properties, e.g., name and type, whose values are text strings. I want
> Lucene to index these data AND I want to know some kind of identifier for
> that vertex Document. I would prefer to give Lucene that ID, though I might
> be able to tolerate it giving it to me.

Lucene has no schema that would allow you to specify a primary key,
but there is the IndexWriter.updateDocument method that allows for
atomic updates of documents:
http://lucene.apache.org/core/4_2_0/core/org/apache/lucene/index/IndexWriter.html#updateDocument(org.apache.lucene.index.Term,
java.lang.Iterable)

You just need to pass a term where the field name is the name of your
primary key field and the value is the actual ID.

-- 
Adrien

---------------------------------------------------------------------
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