You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by lingaraju <li...@infactindia.com> on 2004/07/27 15:21:07 UTC

docfaq of IndexReader is showing the deleted document also

I used the below code

IndexReader reader = IndexReader.open("c:/index");
Term term = new Term("contents","books");
int i=reader.docFreq(term);
System.out.println("docfaq:"+i);
reader.delete(term);
i=reader.docFreq(term);
System.out.println("docfaq:"+i);
reader.close();

reader.docFreq method is returning 10 count before delete even after delete
also count is showing same why

Regards
Raju



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


RE: Powerpoint search using Lucene

Posted by Stephane James Vaucher <va...@cirano.qc.ca>.
I've seen a post on poi-user list with some more code. The links have been
added to the wiki.

http://wiki.apache.org/jakarta-lucene/PowerPoint

sv

On Thu, 29 Jul 2004, Divya S. Jesuraj wrote:

> The second link - does things a bit differently than one would expect.
>
> It creates multiple files "1.txt", "2.txt", so on, extracts the text and
> keeps it only in "1.txt" and doesn't save the name of the initial powerpoint
> file so it can't link to it when you search for it.
>
> What would be ideal is to extract the powerpoint text into an object
> {String?} and create a Lucene Doc that would add it to the index...
>
> I have been playing with the idea of using the code by Mr.Koundinya and
> somehow storing those contents to a string object which then got added as
> "content" to the Lucene Doc. The file name ( .ppt ) and path would get added
> too...will let you folks know how it goes...
>
> ~Divya
>
> -----Original Message-----
> From: Stephane James Vaucher [mailto:vauchers@cirano.qc.ca]
> Sent: Wednesday, July 28, 2004 11:41 PM
> To: Lucene Developers List
> Subject: Re: Powerpoint search using Lucene
>
> I haven't, I've found a few link though...
>
> I just saw this on the poi list. I can't confirm if it works or not (if
> you try it, can you tell us)
>
> http://www.mail-archive.com/poi-user@jakarta.apache.org/msg04782.html
>
> This is a reference to some code that I found works on some ppts:
> http://nagoya.apache.org/eyebrowse/ReadMsg?listName=poi-dev@jakarta.apache.o
> rg&msgNo=4326
>
> sv
>
> On Wed, 28 Jul 2004, Divya S. Jesuraj wrote:
>
> > Hello,
> >
> > I am a VERY new Java Programmer and have now been thrust into development
> > using Lucene. I was able to figure out parsing/indexing of MS Word, MS
> > Excel, RTF, Text files, and PDFs with a lot of reading and using Poi& PDF
> > Sandbox. I however haven't been able to do anything with PPTs [or htmls -
> > that is the least of my worries]...
> >
> > I am indexing a directory on my machine and have a user interface with a
> > JSP. Has anyone figured out how to get a Powerpoint search to work? I
> > searched the forums but I can't find anything that would help my
> situation.
> > Some sample code would be appreciated.
> >
> > Thank you.
> >
> > ~Divya Jesuraj
> > Technical Summer Intern 2004
> > MITRE Corporation
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: lucene-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: lucene-dev-help@jakarta.apache.org
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: lucene-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: lucene-dev-help@jakarta.apache.org
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: lucene-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: lucene-dev-help@jakarta.apache.org
>


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


RE: Powerpoint search using Lucene

Posted by "Divya S. Jesuraj" <dj...@mitre.org>.
The second link - does things a bit differently than one would expect.

It creates multiple files "1.txt", "2.txt", so on, extracts the text and
keeps it only in "1.txt" and doesn't save the name of the initial powerpoint
file so it can't link to it when you search for it.

What would be ideal is to extract the powerpoint text into an object
{String?} and create a Lucene Doc that would add it to the index...

I have been playing with the idea of using the code by Mr.Koundinya and
somehow storing those contents to a string object which then got added as
"content" to the Lucene Doc. The file name ( .ppt ) and path would get added
too...will let you folks know how it goes...

~Divya

-----Original Message-----
From: Stephane James Vaucher [mailto:vauchers@cirano.qc.ca] 
Sent: Wednesday, July 28, 2004 11:41 PM
To: Lucene Developers List
Subject: Re: Powerpoint search using Lucene

I haven't, I've found a few link though...

I just saw this on the poi list. I can't confirm if it works or not (if
you try it, can you tell us)

http://www.mail-archive.com/poi-user@jakarta.apache.org/msg04782.html

This is a reference to some code that I found works on some ppts:
http://nagoya.apache.org/eyebrowse/ReadMsg?listName=poi-dev@jakarta.apache.o
rg&msgNo=4326

sv

On Wed, 28 Jul 2004, Divya S. Jesuraj wrote:

> Hello,
>
> I am a VERY new Java Programmer and have now been thrust into development
> using Lucene. I was able to figure out parsing/indexing of MS Word, MS
> Excel, RTF, Text files, and PDFs with a lot of reading and using Poi& PDF
> Sandbox. I however haven't been able to do anything with PPTs [or htmls -
> that is the least of my worries]...
>
> I am indexing a directory on my machine and have a user interface with a
> JSP. Has anyone figured out how to get a Powerpoint search to work? I
> searched the forums but I can't find anything that would help my
situation.
> Some sample code would be appreciated.
>
> Thank you.
>
> ~Divya Jesuraj
> Technical Summer Intern 2004
> MITRE Corporation
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: lucene-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: lucene-dev-help@jakarta.apache.org
>


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




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


Re: Powerpoint search using Lucene

Posted by Stephane James Vaucher <va...@cirano.qc.ca>.
I haven't, I've found a few link though...

I just saw this on the poi list. I can't confirm if it works or not (if
you try it, can you tell us)

http://www.mail-archive.com/poi-user@jakarta.apache.org/msg04782.html

This is a reference to some code that I found works on some ppts:
http://nagoya.apache.org/eyebrowse/ReadMsg?listName=poi-dev@jakarta.apache.org&msgNo=4326

sv

On Wed, 28 Jul 2004, Divya S. Jesuraj wrote:

> Hello,
>
> I am a VERY new Java Programmer and have now been thrust into development
> using Lucene. I was able to figure out parsing/indexing of MS Word, MS
> Excel, RTF, Text files, and PDFs with a lot of reading and using Poi& PDF
> Sandbox. I however haven't been able to do anything with PPTs [or htmls -
> that is the least of my worries]...
>
> I am indexing a directory on my machine and have a user interface with a
> JSP. Has anyone figured out how to get a Powerpoint search to work? I
> searched the forums but I can't find anything that would help my situation.
> Some sample code would be appreciated.
>
> Thank you.
>
> ~Divya Jesuraj
> Technical Summer Intern 2004
> MITRE Corporation
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: lucene-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: lucene-dev-help@jakarta.apache.org
>


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


Powerpoint search using Lucene

Posted by "Divya S. Jesuraj" <dj...@mitre.org>.
Hello,

I am a VERY new Java Programmer and have now been thrust into development
using Lucene. I was able to figure out parsing/indexing of MS Word, MS
Excel, RTF, Text files, and PDFs with a lot of reading and using Poi& PDF
Sandbox. I however haven't been able to do anything with PPTs [or htmls -
that is the least of my worries]...

I am indexing a directory on my machine and have a user interface with a
JSP. Has anyone figured out how to get a Powerpoint search to work? I
searched the forums but I can't find anything that would help my situation.
Some sample code would be appreciated.

Thank you.

~Divya Jesuraj
Technical Summer Intern 2004
MITRE Corporation



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


Re: docfaq of IndexReader is showing the deleted document also

Posted by Bernhard Messer <Be...@intrafind.de>.
hi,

the code example you posted is working, but as you mentioned before you 
have the problem that the docFreq is updated only when closing the 
IndexWriter. The method i would prefer is to run a simple query and 
check if you get extactly one hit.  This has the advantage that it is 
returning the correct result when a doc is deleted within the 
IndexReader, before storing the index.

TermQuery tq = new TermQuery(new Term("OID", key));
IndexSearcher luceneSearcher = new IndexSearcher(IndexDirectory);
Hits hits = luceneSearcher.search(tq);
if (hits.length() == 1) {
.... doc is in index
}

regards
Bernhard


lingaraju wrote:

>Thanks for information
>I have read the documentation for the IndexReader.delete. method
>After "Indexwriter optimize()" method "docFreq" is giving correct count I
>mean excluding deleted document
>I am having one more question
>Actually I am using docFreq method to find the particular document is
>present or not in index by using key(Unique) field OID
>
>  IndexReader reader = IndexReader.open("c:/index");
>  Term term = new Term("OID","9365");
>  int i=reader.docFreq(term);
>  if (i!=0)
>  {System.out.println("Document present the index:"+i); }
>
>This is the right way or is there any way to find out?
>
>Regards
>Raju
>
>
>
>----- Original Message ----- 
>From: "Bernhard Messer" <Be...@intrafind.de>
>To: "Lucene Developers List" <lu...@jakarta.apache.org>
>Sent: Tuesday, July 27, 2004 7:28 PM
>Subject: Re: docfaq of IndexReader is showing the deleted document also
>
>
>  
>
>>Hi Raju,
>>
>>read the documentation for the IndexReader.delete method and you will
>>find your way ;-)
>>
>>/** Deletes the document numbered <code>docNum</code>.  Once a document is
>>   deleted it will not appear in TermDocs or TermPostitions enumerations.
>>   Attempts to read its field with the {@link #document}
>>   method will result in an error.  The presence of this document may
>>still be
>>   reflected in the {@link #docFreq} statistic, though
>>   this will be corrected eventually as the index is further modified.
>>   */
>>
>>public final synchronized void delete(int docNum) throws IOException
>>
>>
>>regards
>>Bernhard
>>
>>lingaraju wrote:
>>
>>    
>>
>>>I used the below code
>>>
>>>reader.delete(term);
>>>i=reader.docFreq(term);
>>>System.out.println("docfaq:"+i);
>>>reader.close();
>>>
>>>reader.docFreq method is returning 10 count before delete even after
>>>      
>>>
>delete
>  
>
>>>also count is showing same why
>>>
>>>Regards
>>>Raju
>>>
>>>
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: lucene-dev-unsubscribe@jakarta.apache.org
>>>For additional commands, e-mail: lucene-dev-help@jakarta.apache.org
>>>
>>>
>>>
>>>
>>>      
>>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: lucene-dev-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: lucene-dev-help@jakarta.apache.org
>>
>>
>>    
>>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: lucene-dev-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: lucene-dev-help@jakarta.apache.org
>
>  
>


Re: docfaq of IndexReader is showing the deleted document also

Posted by Otis Gospodnetic <ot...@yahoo.com>.
Moved to the more appropriate lucene-user list.

Why don't you just use IndexSearcher with TermQuery with new
Term("OID","9365") ?

The search with such TermQuery will get you 1 or 0 hits, assuming OID
acts as a primary key.  1 if OID=9365 has not been deleted, 0
otherwise.

Otis

--- lingaraju <li...@infactindia.com> wrote:

> 
> Thanks for information
> I have read the documentation for the IndexReader.delete. method
> After "Indexwriter optimize()" method "docFreq" is giving correct
> count I
> mean excluding deleted document
> I am having one more question
> Actually I am using docFreq method to find the particular document is
> present or not in index by using key(Unique) field OID
> 
>   IndexReader reader = IndexReader.open("c:/index");
>   Term term = new Term("OID","9365");
>   int i=reader.docFreq(term);
>   if (i!=0)
>   {System.out.println("Document present the index:"+i); }
> 
> This is the right way or is there any way to find out?
> 
> Regards
> Raju
> 
> 
> 
> ----- Original Message ----- 
> From: "Bernhard Messer" <Be...@intrafind.de>
> To: "Lucene Developers List" <lu...@jakarta.apache.org>
> Sent: Tuesday, July 27, 2004 7:28 PM
> Subject: Re: docfaq of IndexReader is showing the deleted document
> also
> 
> 
> > Hi Raju,
> >
> > read the documentation for the IndexReader.delete method and you
> will
> > find your way ;-)
> >
> > /** Deletes the document numbered <code>docNum</code>.  Once a
> document is
> >    deleted it will not appear in TermDocs or TermPostitions
> enumerations.
> >    Attempts to read its field with the {@link #document}
> >    method will result in an error.  The presence of this document
> may
> > still be
> >    reflected in the {@link #docFreq} statistic, though
> >    this will be corrected eventually as the index is further
> modified.
> >    */
> >
> > public final synchronized void delete(int docNum) throws
> IOException
> >
> >
> > regards
> > Bernhard
> >
> > lingaraju wrote:
> >
> > >I used the below code
> > >
> > >reader.delete(term);
> > >i=reader.docFreq(term);
> > >System.out.println("docfaq:"+i);
> > >reader.close();
> > >
> > >reader.docFreq method is returning 10 count before delete even
> after
> delete
> > >also count is showing same why
> > >
> > >Regards
> > >Raju
> > >
> > >
> > >
> >
>
>---------------------------------------------------------------------
> > >To unsubscribe, e-mail: lucene-dev-unsubscribe@jakarta.apache.org
> > >For additional commands, e-mail:
> lucene-dev-help@jakarta.apache.org
> > >
> > >
> > >
> > >
> >
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: lucene-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: lucene-dev-help@jakarta.apache.org
> >
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: lucene-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: lucene-dev-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: docfaq of IndexReader is showing the deleted document also

Posted by lingaraju <li...@infactindia.com>.
Thanks for information
I have read the documentation for the IndexReader.delete. method
After "Indexwriter optimize()" method "docFreq" is giving correct count I
mean excluding deleted document
I am having one more question
Actually I am using docFreq method to find the particular document is
present or not in index by using key(Unique) field OID

  IndexReader reader = IndexReader.open("c:/index");
  Term term = new Term("OID","9365");
  int i=reader.docFreq(term);
  if (i!=0)
  {System.out.println("Document present the index:"+i); }

This is the right way or is there any way to find out?

Regards
Raju



----- Original Message ----- 
From: "Bernhard Messer" <Be...@intrafind.de>
To: "Lucene Developers List" <lu...@jakarta.apache.org>
Sent: Tuesday, July 27, 2004 7:28 PM
Subject: Re: docfaq of IndexReader is showing the deleted document also


> Hi Raju,
>
> read the documentation for the IndexReader.delete method and you will
> find your way ;-)
>
> /** Deletes the document numbered <code>docNum</code>.  Once a document is
>    deleted it will not appear in TermDocs or TermPostitions enumerations.
>    Attempts to read its field with the {@link #document}
>    method will result in an error.  The presence of this document may
> still be
>    reflected in the {@link #docFreq} statistic, though
>    this will be corrected eventually as the index is further modified.
>    */
>
> public final synchronized void delete(int docNum) throws IOException
>
>
> regards
> Bernhard
>
> lingaraju wrote:
>
> >I used the below code
> >
> >reader.delete(term);
> >i=reader.docFreq(term);
> >System.out.println("docfaq:"+i);
> >reader.close();
> >
> >reader.docFreq method is returning 10 count before delete even after
delete
> >also count is showing same why
> >
> >Regards
> >Raju
> >
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: lucene-dev-unsubscribe@jakarta.apache.org
> >For additional commands, e-mail: lucene-dev-help@jakarta.apache.org
> >
> >
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: lucene-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: lucene-dev-help@jakarta.apache.org
>
>


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


Re: docfaq of IndexReader is showing the deleted document also

Posted by Bernhard Messer <Be...@intrafind.de>.
Hi Raju,

read the documentation for the IndexReader.delete method and you will 
find your way ;-)

/** Deletes the document numbered <code>docNum</code>.  Once a document is
   deleted it will not appear in TermDocs or TermPostitions enumerations.
   Attempts to read its field with the {@link #document}
   method will result in an error.  The presence of this document may 
still be
   reflected in the {@link #docFreq} statistic, though
   this will be corrected eventually as the index is further modified.
   */

public final synchronized void delete(int docNum) throws IOException


regards
Bernhard

lingaraju wrote:

>I used the below code
>
>IndexReader reader = IndexReader.open("c:/index");
>Term term = new Term("contents","books");
>int i=reader.docFreq(term);
>System.out.println("docfaq:"+i);
>reader.delete(term);
>i=reader.docFreq(term);
>System.out.println("docfaq:"+i);
>reader.close();
>
>reader.docFreq method is returning 10 count before delete even after delete
>also count is showing same why
>
>Regards
>Raju
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: lucene-dev-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: lucene-dev-help@jakarta.apache.org
>
>
>  
>


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