Re: auto-generate uid?
Not exactly sure what you're trying to do. You can easily generate a number when you index each Document and insert it in a uid field (which is, BTW, what I do), and if you base it on a timestamp plus some characteristic of the document (which is also what I do), it should always be unique. As you add more documents, they will each get their own unique id. When you delete documents and optimize, these ids won't be affected. However, in your subsequent clarification, you indicated you already had a unique id, and want to find the maximum value. So why did you say you want one auto-generated? Terry - Original Message - From: aurora To: [EMAIL PROTECTED] Sent: Monday, November 22, 2004 4:39 PM Subject: Re: auto-generate uid? Just to clarify. I have a Field 'uid' those value is an unique integer. I use it as a key to the document stored externally. I don't mean Lucene's internal document number. I was wonder if there is a method to query the highest value of a field, perhaps something like: IndexReader.maxTerm('uid') > What would the purpose of an auto-generated UID be? > > But no, Lucene does not generate UID's for you. Documents are numbered > internally by their insertion order. This number changes, however, when > documents are deleted in the middle and the index is optimized. > > Erik > > On Nov 22, 2004, at 1:50 PM, aurora wrote: > >> Is there a way to auto-generate uid in Lucene? Even it is just a way to >> query the highest uid and let the application add one to it will do. >> >> Thanks. >> >> >> - >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> For additional commands, e-mail: [EMAIL PROTECTED] -- Using Opera's revolutionary e-mail client: http://www.opera.com/m2/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: auto-generate uid?
Just to clarify. I have a Field 'uid' those value is an unique integer. I use it as a key to the document stored externally. I don't mean Lucene's internal document number. I was wonder if there is a method to query the highest value of a field, perhaps something like: IndexReader.maxTerm('uid') what you could do is to write your own IndexWriter class by extending the original one found in org.apache.lucene.index.IndexWriter. Than you have direct access to lucene's segment counter which could provide you a unique id for each document in the index. Those id's would stay sticky even if you modify the index after the intial creation process. is that the hint you need to start ? regards Bernhard What would the purpose of an auto-generated UID be? But no, Lucene does not generate UID's for you. Documents are numbered internally by their insertion order. This number changes, however, when documents are deleted in the middle and the index is optimized. Erik On Nov 22, 2004, at 1:50 PM, aurora wrote: Is there a way to auto-generate uid in Lucene? Even it is just a way to query the highest uid and let the application add one to it will do. Thanks. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: auto-generate uid?
On Nov 22, 2004, at 4:39 PM, aurora wrote: Just to clarify. I have a Field 'uid' those value is an unique integer. I use it as a key to the document stored externally. I don't mean Lucene's internal document number. I was wonder if there is a method to query the highest value of a field, perhaps something like: IndexReader.maxTerm('uid') There isn't quite that type of API, though you can skip to a known one and enumerate from there: http://jakarta.apache.org/lucene/docs/api/org/apache/lucene/index/ TermEnum.html#skipTo(org.apache.lucene.index.Term) IndexReader gives you a TermEnum from either the terms() method or the terms(Term) method. Erik What would the purpose of an auto-generated UID be? But no, Lucene does not generate UID's for you. Documents are numbered internally by their insertion order. This number changes, however, when documents are deleted in the middle and the index is optimized. Erik On Nov 22, 2004, at 1:50 PM, aurora wrote: Is there a way to auto-generate uid in Lucene? Even it is just a way to query the highest uid and let the application add one to it will do. Thanks. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Using Opera's revolutionary e-mail client: http://www.opera.com/m2/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: auto-generate uid?
Just to clarify. I have a Field 'uid' those value is an unique integer. I use it as a key to the document stored externally. I don't mean Lucene's internal document number. I was wonder if there is a method to query the highest value of a field, perhaps something like: IndexReader.maxTerm('uid') What would the purpose of an auto-generated UID be? But no, Lucene does not generate UID's for you. Documents are numbered internally by their insertion order. This number changes, however, when documents are deleted in the middle and the index is optimized. Erik On Nov 22, 2004, at 1:50 PM, aurora wrote: Is there a way to auto-generate uid in Lucene? Even it is just a way to query the highest uid and let the application add one to it will do. Thanks. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Using Opera's revolutionary e-mail client: http://www.opera.com/m2/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: auto-generate uid?
What would the purpose of an auto-generated UID be? But no, Lucene does not generate UID's for you. Documents are numbered internally by their insertion order. This number changes, however, when documents are deleted in the middle and the index is optimized. Erik On Nov 22, 2004, at 1:50 PM, aurora wrote: Is there a way to auto-generate uid in Lucene? Even it is just a way to query the highest uid and let the application add one to it will do. Thanks. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
auto-generate uid?
Is there a way to auto-generate uid in Lucene? Even it is just a way to query the highest uid and let the application add one to it will do. Thanks. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]