Taking a quick glance at the code, I don't see anything
obviously wrong as far as the problem you describe goes.

What happens if you just add a required clause to your query
string rather than use a Filter? Something like
+sentiment:positive? If you do that, query.toString is
your friend <G>...

Erick


On Tue, Mar 2, 2010 at 10:04 AM, Dyutiman <dyutiman.chaudh...@gmail.com>wrote:

>
> Thanks Erick for your quick reply.
> I am going to try Luke and examine my index. In the mean time let me tell
> you that I am indexing the documents every time creating the new document.
> Let me attach the code I am using here.
>
> thanks
> Dyutiman http://old.nabble.com/file/p27756896/IndexUtil.javaIndexUtil.java
>
>
>
>
> Erick Erickson wrote:
> >
> > 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
> > like
> > 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....
> >
> > HTH
> > Erick
> >
> > On Tue, Mar 2, 2010 at 9:35 AM, Dyutiman
> > <dyutiman.chaudh...@gmail.com>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,
> >> Field.Index.NOT_ANALYZED_NO_NORMS));
> >>
> >> 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 = searcher.search(query, 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:
> >> http://old.nabble.com/Lucene-Filter-tp27756577p27756577.html
> >> Sent from the Lucene - Java Developer mailing list archive at
> Nabble.com.
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: java-dev-unsubscr...@lucene.apache.org
> >> For additional commands, e-mail: java-dev-h...@lucene.apache.org
> >>
> >>
> >
> >
>
> --
> View this message in context:
> http://old.nabble.com/Lucene-Filter-tp27756577p27756896.html
> Sent from the Lucene - Java Developer mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-dev-unsubscr...@lucene.apache.org
> For additional commands, e-mail: java-dev-h...@lucene.apache.org
>
>

Reply via email to