Mailing List Archive

IndexReader/IndexSearcher
Hi all.

Can somebody tell me where is my error.
There is something I don't understand.

If I search something with

IndexReader indexReader = IndexReader.open("/myindex");
TermDocs docs = indexReader.termDocs(new Term("codman", "BO23"));
while ( (docs!=null) && (docs.next()) ) {
nbis++;
}
if (docs!=null) docs.close();
indexReader.close();

I see that nbis = 0 so temDocs returned nothing.

But, If I use

SimpleAnalyzer analyzer = new SimpleAnalyzer();
IndexSearcher indexSearcher = new IndexSearcher("/myindex");
Query query = QueryParser.parse("BO23", "codman", analyzer);
Hits hits = indexSearcher.search(query);
nbis = hits.length();

It's exactly the same query, the same index but this time, it return 1
document.

I don't understand where this difference came from ?
I know that the firs way is not the good way of searching but what I wan't
is to delete from the index the document returned wy the search #2.

Thanks in advance for any help.

Mike



--
To unsubscribe, e-mail: <mailto:lucene-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:lucene-user-help@jakarta.apache.org>
Re: IndexReader/IndexSearcher [ In reply to ]
I reply to myself :

It seem that when using IndexReader, keywords must be lower case.
So, I indexed BO23, I can search BO23 with IndexSearcher, but I must use
bo23 to search with IndexReader.

Am I right ?

Mike

----- Original Message -----
From: "Mike Baroukh" <mbaroukh@cardiweb.com>
To: "Lucene Users List" <lucene-user@jakarta.apache.org>
Sent: Wednesday, December 19, 2001 12:57 PM
Subject: IndexReader/IndexSearcher


>
> Hi all.
>
> Can somebody tell me where is my error.
> There is something I don't understand.
>
> If I search something with
>
> IndexReader indexReader = IndexReader.open("/myindex");
> TermDocs docs = indexReader.termDocs(new Term("codman", "BO23"));
> while ( (docs!=null) && (docs.next()) ) {
> nbis++;
> }
> if (docs!=null) docs.close();
> indexReader.close();
>
> I see that nbis = 0 so temDocs returned nothing.
>
> But, If I use
>
> SimpleAnalyzer analyzer = new SimpleAnalyzer();
> IndexSearcher indexSearcher = new IndexSearcher("/myindex");
> Query query = QueryParser.parse("BO23", "codman", analyzer);
> Hits hits = indexSearcher.search(query);
> nbis = hits.length();
>
> It's exactly the same query, the same index but this time, it return 1
> document.
>
> I don't understand where this difference came from ?
> I know that the firs way is not the good way of searching but what I wan't
> is to delete from the index the document returned wy the search #2.
>
> Thanks in advance for any help.
>
> Mike
>
>
>
> --
> To unsubscribe, e-mail:
<mailto:lucene-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail:
<mailto:lucene-user-help@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail: <mailto:lucene-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:lucene-user-help@jakarta.apache.org>
Re: IndexReader/IndexSearcher [ In reply to ]
Uh, I don't repeat myself, but I'll repeat others' words :)

It is the analyzer (StandardAnalyzer, I believe) that lowercases text
before indexing it.
If you use the same analyzer to search it will lowercase text before
performing a search, so you'll find the document with bo23 in it even
if you use BO23 in the search.

Otis

--- Mike Baroukh <mbaroukh@cardiweb.com> wrote:
> I reply to myself :
>
> It seem that when using IndexReader, keywords must be lower case.
> So, I indexed BO23, I can search BO23 with IndexSearcher, but I must
> use
> bo23 to search with IndexReader.
>
> Am I right ?
>
> Mike
>
> ----- Original Message -----
> From: "Mike Baroukh" <mbaroukh@cardiweb.com>
> To: "Lucene Users List" <lucene-user@jakarta.apache.org>
> Sent: Wednesday, December 19, 2001 12:57 PM
> Subject: IndexReader/IndexSearcher
>
>
> >
> > Hi all.
> >
> > Can somebody tell me where is my error.
> > There is something I don't understand.
> >
> > If I search something with
> >
> > IndexReader indexReader = IndexReader.open("/myindex");
> > TermDocs docs = indexReader.termDocs(new Term("codman",
> "BO23"));
> > while ( (docs!=null) && (docs.next()) ) {
> > nbis++;
> > }
> > if (docs!=null) docs.close();
> > indexReader.close();
> >
> > I see that nbis = 0 so temDocs returned nothing.
> >
> > But, If I use
> >
> > SimpleAnalyzer analyzer = new SimpleAnalyzer();
> > IndexSearcher indexSearcher = new IndexSearcher("/myindex");
> > Query query = QueryParser.parse("BO23", "codman", analyzer);
> > Hits hits = indexSearcher.search(query);
> > nbis = hits.length();
> >
> > It's exactly the same query, the same index but this time, it
> return 1
> > document.
> >
> > I don't understand where this difference came from ?
> > I know that the firs way is not the good way of searching but what
> I wan't
> > is to delete from the index the document returned wy the search #2.
> >
> > Thanks in advance for any help.
> >
> > Mike
> >
> >
> >
> > --
> > To unsubscribe, e-mail:
> <mailto:lucene-user-unsubscribe@jakarta.apache.org>
> > For additional commands, e-mail:
> <mailto:lucene-user-help@jakarta.apache.org>
> >
> >
>
>
> --
> To unsubscribe, e-mail:
> <mailto:lucene-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail:
> <mailto:lucene-user-help@jakarta.apache.org>
>


__________________________________________________
Do You Yahoo!?
Check out Yahoo! Shopping and Yahoo! Auctions for all of
your unique holiday gifts! Buy at http://shopping.yahoo.com
or bid at http://auctions.yahoo.com

--
To unsubscribe, e-mail: <mailto:lucene-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:lucene-user-help@jakarta.apache.org>
Re: IndexReader/IndexSearcher [ In reply to ]
Thanks a lot. It's clear for me now !


----- Original Message -----
From: "Otis Gospodnetic" <otis_gospodnetic@yahoo.com>
To: "Lucene Users List" <lucene-user@jakarta.apache.org>
Sent: Wednesday, December 19, 2001 4:19 PM
Subject: Re: IndexReader/IndexSearcher


> Uh, I don't repeat myself, but I'll repeat others' words :)
>
> It is the analyzer (StandardAnalyzer, I believe) that lowercases text
> before indexing it.
> If you use the same analyzer to search it will lowercase text before
> performing a search, so you'll find the document with bo23 in it even
> if you use BO23 in the search.
>
> Otis
>
> --- Mike Baroukh <mbaroukh@cardiweb.com> wrote:
> > I reply to myself :
> >
> > It seem that when using IndexReader, keywords must be lower case.
> > So, I indexed BO23, I can search BO23 with IndexSearcher, but I must
> > use
> > bo23 to search with IndexReader.
> >
> > Am I right ?
> >
> > Mike
> >
> > ----- Original Message -----
> > From: "Mike Baroukh" <mbaroukh@cardiweb.com>
> > To: "Lucene Users List" <lucene-user@jakarta.apache.org>
> > Sent: Wednesday, December 19, 2001 12:57 PM
> > Subject: IndexReader/IndexSearcher
> >
> >
> > >
> > > Hi all.
> > >
> > > Can somebody tell me where is my error.
> > > There is something I don't understand.
> > >
> > > If I search something with
> > >
> > > IndexReader indexReader = IndexReader.open("/myindex");
> > > TermDocs docs = indexReader.termDocs(new Term("codman",
> > "BO23"));
> > > while ( (docs!=null) && (docs.next()) ) {
> > > nbis++;
> > > }
> > > if (docs!=null) docs.close();
> > > indexReader.close();
> > >
> > > I see that nbis = 0 so temDocs returned nothing.
> > >
> > > But, If I use
> > >
> > > SimpleAnalyzer analyzer = new SimpleAnalyzer();
> > > IndexSearcher indexSearcher = new IndexSearcher("/myindex");
> > > Query query = QueryParser.parse("BO23", "codman", analyzer);
> > > Hits hits = indexSearcher.search(query);
> > > nbis = hits.length();
> > >
> > > It's exactly the same query, the same index but this time, it
> > return 1
> > > document.
> > >
> > > I don't understand where this difference came from ?
> > > I know that the firs way is not the good way of searching but what
> > I wan't
> > > is to delete from the index the document returned wy the search #2.
> > >
> > > Thanks in advance for any help.
> > >
> > > Mike
> > >
> > >
> > >
> > > --
> > > To unsubscribe, e-mail:
> > <mailto:lucene-user-unsubscribe@jakarta.apache.org>
> > > For additional commands, e-mail:
> > <mailto:lucene-user-help@jakarta.apache.org>
> > >
> > >
> >
> >
> > --
> > To unsubscribe, e-mail:
> > <mailto:lucene-user-unsubscribe@jakarta.apache.org>
> > For additional commands, e-mail:
> > <mailto:lucene-user-help@jakarta.apache.org>
> >
>
>
> __________________________________________________
> Do You Yahoo!?
> Check out Yahoo! Shopping and Yahoo! Auctions for all of
> your unique holiday gifts! Buy at http://shopping.yahoo.com
> or bid at http://auctions.yahoo.com
>
> --
> To unsubscribe, e-mail:
<mailto:lucene-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail:
<mailto:lucene-user-help@jakarta.apache.org>
>
>


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