First, have you tried looking at bq.toString() to see what your query looks
like?

But from your code, you're not assigning your createTerm to anything, so
your
BQ is constructed from two terms on "field" that have no values. You need
something like

bq.add(t.createTerm("foo), Occur.MUST);

Best
Erick

On Mon, Jun 16, 2008 at 4:25 AM, Sascha Fahl <[EMAIL PROTECTED]>
wrote:

> Hi,
>
> I'm trying to build my own query. I want to combine several TermQuery + 1
> PrefixQuery in a BooleanQuery. The Code looks like this:
> BooleanQuery bq = new BooleanQuery();
>
> Term t = new Term("field", "");
>
> t.createTerm("foo");
> TermQuery tq = new TermQuery(t);
> bq.add(tq, Occur.MUST);
>
> t.createTerm("bar");
> PrefixQuery pq = new PrefixQuery(t);
> bq.add(pq, Occur.MUST);
>
> So bq is my customized BooleanQuery. Searching with this query results in 0
> hits. But working with QueryParser.parse()
> and the parameter "foo AND bar*" results in a high number of hits. Looking
> at the query string shows the same result
> for the QueryParser querystring and the customized BooleanQuery
> querystring.
> What could be the problem with my customized query?
>
> Sascha
>
>

Reply via email to