lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Uwe Schindler" <...@thetaphi.de>
Subject RE: How index and search text files in Lucene 3.0.2 ?
Date Fri, 05 Nov 2010 16:06:46 GMT
Hi Celso,

just a note, your code makes no sense:

In the constructor of QueryParser you have to give the default field, e.g.
"content" only - With parse() you have to give the query string (which can
contain a field name or not): "computer" or alternatively "content:computer"
(which returns equal results because the default field from the ctor is
content:

QueryParser parser = new QueryParser(Version.LUCENE_30, "content",
analyzer);
Query query = parser.parse("computer");

or:

Query query = parser.parse("content:computer");

Uwe

-----
Uwe Schindler
H.-H.-Meier-Allee 63, D-28213 Bremen
http://www.thetaphi.de
eMail: uwe@thetaphi.de


> -----Original Message-----
> From: Celso Fontes [mailto:celsowm@gmail.com]
> Sent: Friday, November 05, 2010 5:01 PM
> To: java-user@lucene.apache.org
> Subject: Re: How index and search text files in Lucene 3.0.2 ?
> 
> Thanks Uwe, its works with:
> 
>             QueryParser parser = new QueryParser(Version.LUCENE_30,
> "content:computer", analyzer);
>             Query query = parser.parse("content:computer");
> 
> But, if i need get results like google in a query like "What is the role
of PrnP in
> mad cow disease?"
> 
> Thanks
> CElso.
> 
> 2010/11/5 Uwe Schindler <uwe@thetaphi.de>:
> > The default field of query parser is wrong:
> > QueryParser parser = new QueryParser(Version.LUCENE_30, "computer",
> > analyzer);
> >
> > You haven't indexed a field with name "computer". Your query string
> > does not override the field, so your query is in fact
"computer:computer".
> >
> > A note: It is not recommended to instantiate TopScoreDocCollector
> > directly for such search cases, just use the IndexSearcher method that
> > returns TopDocs!
> >
> > -----
> > Uwe Schindler
> > H.-H.-Meier-Allee 63, D-28213 Bremen
> > http://www.thetaphi.de
> > eMail: uwe@thetaphi.de
> >
> >> -----Original Message-----
> >> From: Celso Fontes [mailto:celsowm@gmail.com]
> >> Sent: Friday, November 05, 2010 3:34 AM
> >> To: java-user@lucene.apache.org
> >> Subject: How index and search text files in Lucene 3.0.2 ?
> >>
> >> Hi ! I am newbie in lucene, and i have some problems to create a
> >> simple
> > code
> >> to query a text file collection.
> >>
> >> My code is this (http://pastebin.com/HqrbBPtp), but does not works.
> >> What is Wrong?
> >>
> >> Thanks,
> >> Celso.
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> >> For additional commands, e-mail: java-user-help@lucene.apache.org
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> > For additional commands, e-mail: java-user-help@lucene.apache.org
> >
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org



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


Mime
View raw message