You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Peter Veentjer - Anchor Men <p....@anchormen.nl> on 2005/01/04 20:43:06 UTC

how to create a long lasting unique key?

What is the best way to create a key for a document? I know the id (from hits) can not be used, but what is a good way to create a key

I need this key for a webapplication. At the moment every document can be identified with the filelocation key, but I would rather some kind of integer for the Job (nobody needs to know the file location).


---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org


Re: how to create a long lasting unique key?

Posted by Luke Shannon <ls...@futurebrand.com>.
This is taken from the example code writen by Doug Cutting that ships with
Lucene.

It is the key our system uses. It also comes in handy when incrementally
updating.

Luke

public static String uid(File f) {
  // Append path and date into a string in such a way that lexicographic
  // sorting gives the same results as a walk of the file hierarchy. Thus
  // null (\u0000) is used both to separate directory components and to
  // separate the path from the date.
  return f.getPath().replace(dirSep, '\u0000') + "\u0000"
    + DateField.timeToString(f.lastModified());
 }

----- Original Message ----- 
From: "Peter Veentjer - Anchor Men" <p....@anchormen.nl>
To: <lu...@jakarta.apache.org>
Sent: Tuesday, January 04, 2005 2:43 PM
Subject: how to create a long lasting unique key?


What is the best way to create a key for a document? I know the id (from
hits) can not be used, but what is a good way to create a key

I need this key for a webapplication. At the moment every document can be
identified with the filelocation key, but I would rather some kind of
integer for the Job (nobody needs to know the file location).


---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org


Re: how to create a long lasting unique key?

Posted by PA <pe...@gmail.com>.
On Jan 04, 2005, at 20:43, Peter Veentjer - Anchor Men wrote:

> What is the best way to create a key for a document?

UUID?

http://java.sun.com/j2se/1.5.0/docs/api/java/util/UUID.html


---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org