You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Anna Putnam <an...@sendmemobile.com> on 2007/05/16 03:00:18 UTC
QueryFilter usage
Hi all,
I am new to Lucene so I apologize if this is a really easy question. I
am having trouble using the QueryFilter class.
Basically, I want to narrow my search results, getting hits only for a
particular category.
This is what I've tried (getting no results)
String line ="justin";
Query query = parser.parse(line);
System.out.println("Query: " + query.toString());
Term t = new Term("category", "Pop");
TermQuery tq = new TermQuery(t);
QueryFilter qf = new QueryFilter(tq);
System.out.println("Filtered Query: " + fq.toString());
fq = new FilteredQuery(query, qf);
search(fq);
My debug gives the following:
Query: author:justin title:justin
Filtered Query: filtered(author:justin
title:justin)->QueryFilter(category:Pop)
If I call search(query) I get full results so I know "category" is
indexed.
Any help would be greatly appreciated.
-Anna
Re: QueryFilter usage
Posted by Wayne Graham <ws...@wm.edu>.
While I too am still learning, I ran into this last week.
Try this:
String line = "justin";
Query query = parser.parse(line);
TermQuery tq = new TermQuery(new Term("category", "Pop"));
Filter qf = new QueryFilter(tq);
Hits hits = search(query, qf);
HTH,
Wayne
Anna Putnam wrote:
> Hi all,
>
>
>
> I am new to Lucene so I apologize if this is a really easy question. I
> am having trouble using the QueryFilter class.
>
>
>
> Basically, I want to narrow my search results, getting hits only for a
> particular category.
>
>
>
> This is what I've tried (getting no results)
>
>
>
> String line ="justin";
>
> Query query = parser.parse(line);
>
> System.out.println("Query: " + query.toString());
>
> Term t = new Term("category", "Pop");
>
> TermQuery tq = new TermQuery(t);
>
> QueryFilter qf = new QueryFilter(tq);
>
> System.out.println("Filtered Query: " + fq.toString());
>
>
>
> fq = new FilteredQuery(query, qf);
>
>
>
> search(fq);
>
>
>
> My debug gives the following:
>
>
>
> Query: author:justin title:justin
>
> Filtered Query: filtered(author:justin
> title:justin)->QueryFilter(category:Pop)
>
>
>
> If I call search(query) I get full results so I know "category" is
> indexed.
>
>
>
> Any help would be greatly appreciated.
>
>
>
> -Anna
>
>
>
>
--
/**
* Wayne Graham
* Earl Gregg Swem Library
* PO Box 8794
* Williamsburg, VA 23188
* 757.221.3112
* http://swem.wm.edu/blogs/waynegraham/
*/
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
Re: QueryFilter usage
Posted by James Rhodes <jr...@gmail.com>.
unsubscribe