lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erick Erickson <>
Subject Re: Lucene Filter
Date Tue, 02 Mar 2010 14:53:13 GMT
The very first thing I'd recommend is to get a copy of Luke
(google Lucene, Luke) and examine your index to see if
what you *think* is in there is *actually* in there.

One popular "learning experience" is to do something
Document = new Document();
while (<more docs to add>) {
   add field
   add field
   add doc

Problem is that the document simply accumulates. The first
"add doc" puts your first document in the index. The second
puts the contents of both the first and second doc in the
second doc of the index. The third puts the contents of 3
documents in for the third doc, etc.....

Cure this by moving the new Document inside the while loop....

If this doesn't help, please show your indexing and
searching code....


On Tue, Mar 2, 2010 at 9:35 AM, Dyutiman <>wrote:

> Hi,
> I am new in this forum and new to Lucene also. I m getting some issue while
> trying to filter my Lucene result.
> While creating the index I am creating a field called sentiment and
> possible
> values are 'positive', 'negative' & 'neutral', I am indexing this field
> like
> doc.add(new Field("sentiment", sentiment, Field.Store.YES,
> Now I want to search within my index but get only positive sentiment
> results
> for the searched string.
> For this I am doing something like this :
> QueryParser qp = new QueryParser(Version.LUCENE_CURRENT, "contents",
> analyzer);
> Query query = qp.parse(searchString);
> Filter filter = new TermRangeFilter("sentiment", "positive", "positive",
> true, true);
> topDocs =, filter, 20);
> But I am getting results mixed with all 3 sentiments. I tried other filters
> also but the result is same.
> Anybody got any solutions for me please help......
> thanks
> Dyutiman
> --
> View this message in context:
> Sent from the Lucene - Java Developer mailing list archive at
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

View raw message