lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "umamahesh bayireddya" <umamahes...@hotmail.com>
Subject update and search in parallel
Date Fri, 27 Feb 2004 19:54:05 GMT
hi all

I have two question:
1) Is it possible to update and search a document in parallel ?
2) Is it possible to update and delete a document in parallel ?



my code for update:
public void updateIndexDoc(String url) throws Exception {
         PropertiesHandler ph;
        ph = new PropertiesHandler();
        indexdir = ph.getProperty("index");
        File f = new File(url);
        Directory directory = FSDirectory.getDirectory(indexdir, false);

        IndexReader reader = IndexReader.open(directory);

         int j =-1;
        for(int i =0; i<reader.numDocs();i++)
         {
             if(!reader.isDeleted(i))
             {
             Document d = reader.document(i);
             String url1 = d.get("url");
             if(url1.equals(url))
             {
           System.out.println(url1);
                 j=i;

             }
             }
         }
          if(j!=-1)
        reader.delete(j);
        reader.close();
        directory.close();
        create = false;
        writer = new IndexWriter(indexdir, new StandardAnalyzer(), create);
        writer.maxFieldLength = 1000000;
        addIndexDoc(f);
       writer.optimize();
        writer.close();

    }


public void deleteIndexDoc(String url)
            throws IOException {
        PropertiesHandler ph;
        ph = new PropertiesHandler();
        indexdir = ph.getProperty("index");
        File f = new File(url);

        Directory directory = FSDirectory.getDirectory(indexdir, false);

        IndexReader reader = IndexReader.open(directory);


         int j =-1;
        for(int i =0; i<reader.numDocs();i++)
         {
             if(!reader.isDeleted(i))
             {
             Document d = reader.document(i);
             String url1 = d.get("url");
             if(url1.equals(url))
             {
           System.out.println(url1);
                 j=i;

             }
             }
         }

              if(j!=-1)
        reader.delete(j);
        reader.close();
        directory.close();

    }



thanks

mahesh

_________________________________________________________________
INDIA TODAY @ Rs. 5 for 5 years ! 
http://www.indiatoday.com/itoday/intlsubscription/itsubs/it_offer.html 
Subcribe Now ...


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


Mime
View raw message