Delete Indexed from Merged Document
Hello Mr Wolf-Dietrich Materna Apologies on delay reply. I would like to have more of u' Help in this matter, Let me Explain the Setup I am Using in here... 1) I have "X" number of Unique Folders Which have around 50,000 Unique named HTML Files. 2) The Indexing Field factor for each File in each folder is done on basis of A)Name of File, B)Last modified Date C)Content of the file D)Folder in which the File is avaliable. At the end of the Week, Every Unique Indivigual Folder is Indexed Indivigually in seperate folder. And at the end of Month These Unique Indexed Folders are Merged into one file. So in any case If Iwant to Update the Existing Merged Folder,I have to first delete from the Merged index on the basis of Field type ( D as mentioned above) factor which is the Unique Folder name, So u mean to say if I Delete from merged Index on the basis of D, and researching of the Merged Index for the same ,the hits should return me 0 hits. Please advise me in this regard if I am not correct Thx in advance -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Wednesday, June 23, 2004 6:41 PM To: [EMAIL PROTECTED] Subject: AW: Delete Indexed from Merged Document Hello, > Karthik N S [mailto:[EMAIL PROTECTED] wrote: > Hi > Mr Wolf Wolf-Dietrich is my first name, so leave out Mr. or use my family name (which is uncommon here). > What is this > > // remove the document from index > int docID = hits.id(0); > > and can I increment the "0" factor in the bracket ...for deletion Yes, but there is no reason to do this in this case. You search for documents using their file name (including their full path!). You get a result (some kind of list). Please read Java-Docs about Hits class. hits.id(0) returns the (internal) ID of the first hit in your result. This is the document that you want to remove (using indexReader.delete(...).). There are no more documents in your result "hits" unless your key is not unique. hits.length() returns 0 or 1. Regards, Wolf-Dietrich Materna - 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]
AW: Delete Indexed from Merged Document
Hello, > Karthik N S [mailto:[EMAIL PROTECTED] wrote: > Hi > Mr Wolf Wolf-Dietrich is my first name, so leave out Mr. or use my family name (which is uncommon here). > What is this > > // remove the document from index > int docID = hits.id(0); > > and can I increment the "0" factor in the bracket ...for deletion Yes, but there is no reason to do this in this case. You search for documents using their file name (including their full path!). You get a result (some kind of list). Please read Java-Docs about Hits class. hits.id(0) returns the (internal) ID of the first hit in your result. This is the document that you want to remove (using indexReader.delete(...).). There are no more documents in your result "hits" unless your key is not unique. hits.length() returns 0 or 1. Regards, Wolf-Dietrich Materna - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Delete Indexed from Merged Document
Hi Mr Wolf What is this // remove the document from index int docID = hits.id(0); and can I increment the "0" factor in the bracket ...for deletion Thx in advance Karthik -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Wednesday, June 23, 2004 5:33 PM To: [EMAIL PROTECTED] Subject: AW: Delete Indexed from Merged Document Hello, > Karthik N S [mailto:[EMAIL PROTECTED] > >Has Somebody out there tried DELETING/UPDATION of > INDEXED Files from a > MERGED Index Format, > If HowTo do this Please Explain Of course you can delete or update a document from a merged index. It works in the same way as for all other indexes. You need an unique key (e.g. the file name or uri), which is indexed for searching, to find the right document, because the internal document numbers are changed after merging indexes or deleting documents and optimizing an index. Using this key you can search for the document and remove it. It doesn't matter if your index was created by merging serveral indexes or not. Example: /* Create index: */ Document document = new Document(); document.add(Field.Keyword("filename", file_name)); // this must be unique for each document! document.add(Field.Text("content", file_content)); writer.addDocument(document); /* ... */ writer.close(); /* Update or remove document: Use the file name to find the original document and remove it from index */ FSDirectory indexDirectory = FSDirectory.getDirectory("indexPath", false); IndexReader indexReader = IndexReader.open(indexDirectory); IndexSearcher indexSearcher = new IndexSearcher(indexReader); // create query and search for document using its filename TermQuery query = new TermQuery(new Term("filename", file_name)); Hits hits = indexSearcher.search(query); if ( hits.length() > 0 ) { // remove the document from index int docID = hits.id(0); indexReader.delete( docID ); } // else: this is a new file or already removed, so we can simply add it. indexSearcher.close(); indexReader.close(); indexDirectory.close(); // now open an IndexWriter for the same index and add the updated file // as new document /* done */ Hope it helps. Regards, Wolf-Dietrich Materna - 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]
AW: Delete Indexed from Merged Document
Hello, > Karthik N S [mailto:[EMAIL PROTECTED] > >Has Somebody out there tried DELETING/UPDATION of > INDEXED Files from a > MERGED Index Format, > If HowTo do this Please Explain Of course you can delete or update a document from a merged index. It works in the same way as for all other indexes. You need an unique key (e.g. the file name or uri), which is indexed for searching, to find the right document, because the internal document numbers are changed after merging indexes or deleting documents and optimizing an index. Using this key you can search for the document and remove it. It doesn't matter if your index was created by merging serveral indexes or not. Example: /* Create index: */ Document document = new Document(); document.add(Field.Keyword("filename", file_name)); // this must be unique for each document! document.add(Field.Text("content", file_content)); writer.addDocument(document); /* ... */ writer.close(); /* Update or remove document: Use the file name to find the original document and remove it from index */ FSDirectory indexDirectory = FSDirectory.getDirectory("indexPath", false); IndexReader indexReader = IndexReader.open(indexDirectory); IndexSearcher indexSearcher = new IndexSearcher(indexReader); // create query and search for document using its filename TermQuery query = new TermQuery(new Term("filename", file_name)); Hits hits = indexSearcher.search(query); if ( hits.length() > 0 ) { // remove the document from index int docID = hits.id(0); indexReader.delete( docID ); } // else: this is a new file or already removed, so we can simply add it. indexSearcher.close(); indexReader.close(); indexDirectory.close(); // now open an IndexWriter for the same index and add the updated file // as new document /* done */ Hope it helps. Regards, Wolf-Dietrich Materna - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Delete Indexed from Merged Document
Guys Has Somebody out there tried DELETING/UPDATION of INDEXED Files from a MERGED Index Format, If HowTo do this Please Explain with regards Karthik -Original Message- From: Karthik N S [mailto:[EMAIL PROTECTED] Sent: Wednesday, June 23, 2004 9:24 AM To: Lucene Users List Subject: RE: Delete Indexed from Merged Document Hi Otis The link u have specified displays on how to update an Indexed File [ Deleting the Old and then updating with new Ones'] But My Question to be more Specific is : - When we MERGED more then 2 Indexed files [using writer.addIndexes(luceneDirs)] , In such a case How to Delete one of the Indexed files from the MERGED Index in order to Insert an new updated one Please have some sample code snippet in this regard.. with regards Karthik -Original Message- From: Otis Gospodnetic [mailto:[EMAIL PROTECTED] Sent: Tuesday, June 22, 2004 12:52 PM To: Lucene Users List Subject: Re: Delete Indexed from Merged Document Hello Karthik, Here is the answer: http://www.jguru.com/faq/view.jsp?EID=492423 Otis --- Karthik N S <[EMAIL PROTECTED]> wrote: > > > Dev Guys > > Apologies Please > > How Do I DELETE an Indexed Document from a MERGED Index File > >Can Some body Write me some Code Snippets on this... please > > With Regards > Karthik > > - > 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] - 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: Delete Indexed from Merged Document
Hi Otis The link u have specified displays on how to update an Indexed File [ Deleting the Old and then updating with new Ones'] But My Question to be more Specific is : - When we MERGED more then 2 Indexed files [using writer.addIndexes(luceneDirs)] , In such a case How to Delete one of the Indexed files from the MERGED Index in order to Insert an new updated one Please have some sample code snippet in this regard.. with regards Karthik -Original Message- From: Otis Gospodnetic [mailto:[EMAIL PROTECTED] Sent: Tuesday, June 22, 2004 12:52 PM To: Lucene Users List Subject: Re: Delete Indexed from Merged Document Hello Karthik, Here is the answer: http://www.jguru.com/faq/view.jsp?EID=492423 Otis --- Karthik N S <[EMAIL PROTECTED]> wrote: > > > Dev Guys > > Apologies Please > > How Do I DELETE an Indexed Document from a MERGED Index File > >Can Some body Write me some Code Snippets on this... please > > With Regards > Karthik > > - > 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] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Delete Indexed from Merged Document
Hello Karthik, Here is the answer: http://www.jguru.com/faq/view.jsp?EID=492423 Otis --- Karthik N S <[EMAIL PROTECTED]> wrote: > > > Dev Guys > > Apologies Please > > How Do I DELETE an Indexed Document from a MERGED Index File > >Can Some body Write me some Code Snippets on this... please > > With Regards > Karthik > > - > 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]
Delete Indexed from Merged Document
Dev Guys Apologies Please How Do I DELETE an Indexed Document from a MERGED Index File Can Some body Write me some Code Snippets on this... please With Regards Karthik - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]