Delete Indexed from Merged Document

2004-06-23 Thread Karthik N S
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

2004-06-23 Thread Karthik N S

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

2004-06-23 Thread Wolf-Dietrich . Materna
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

2004-06-22 Thread Karthik N S
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]