lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andre Rubin" <andre.ru...@gmail.com>
Subject Re: MultiPhrase search
Date Tue, 26 Aug 2008 18:02:56 GMT
Thanks again Daniel,

It's working now. But for some reason, TermQuery is not working for me (i
think because I have special characters in the query). I replaced the
TermQuery with the query below and I got the results I was expecting.

Thanks!!!!

String escapedType = QueryParser.escape(type);
QueryParser parser = new QueryParser(TYPE_FIELD, ANALYZER);
Query tq = parser.parse(TYPE_FIELD + ":" + escapedType);


Andre

On Tue, Aug 26, 2008 at 10:19 AM, Daniel Naber <
lucenelist2007@danielnaber.de> wrote:

> On Dienstag, 26. August 2008, Andre Rubin wrote:
>
> > Now I was the one who didn't follow: How do I add a query to an existing
> > query?
>
> Something like this should work:
>
> BooleanQuery bq = new BooleanQuery();
> PrefixQuery pq = new PrefixQuery(...);
> bq.add(pq, BooleanClause.Occur.MUST);
> TermQuery tq = new TermQuery(new Term("type", "sequence"));
> bq.add(tq, BooleanClause.Occur.MUST);
>
> bq is now the query you can use for searching. BooleanClause.Occur.MUST
> basically means "AND". So unless you want your users to access the
> features of Lucene's QueryParser (e.g. AND, OR, NOT, fuzzy queries etc)
> there's no need to use it.
>
> Regards
>  Daniel
>
> --
> http://www.danielnaber.de
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message