views:

31

answers:

1

I am attempting query some results using a Boolean Query. However the query does not return any results.

Here is the FilterQuery I am running. This returns no results, even though the field foo contains bar, and the field foo3 contains bar3. And I have triple checked my fields to make sure that the fields do exist in the index.

+(foo:bar foo2:bar2) +foo3:bar3

Now, If I remove the +foo3:bar3 from the query I get results back correctly. Also foo3:bar3 is being added programatically, so I am not parsing it. Here is some relevant code

//This code creates the first part of the query.
MultiFieldQueryParser mfqp = new MultiFieldQueryParser(Lucene.Net.Util.Version.LUCENE_29,SearchFields, analyzer);
        Query q = mfqp.Parse(query);
        BooleanQuery filterquery = new BooleanQuery();
        filterquery.Add(q,BooleanClause.Occur.MUST);

//This code creates the second part of the query
Query fq = new TermQuery(new Term("foo3","bar3"));
filterquery.Add(fq, BooleanClause.Occur.MUST);

//Perform the search
ScoreDoc[] hits = isearch.Search(filterquery, null, ResultsToReturn).scoreDocs;

Just for reference, I am current setting the fields to be analyzed, and the vector is set to With_positions_offsets

A: 

I changed from using a TermQuery, to using a QueryParser, which seems to have fixed the issue.

Aaron M