You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucenenet.apache.org by Ingemar Strandberg <in...@home.se> on 2007/06/28 14:33:41 UTC
Search using BooleanQuery with wildcards or phrases
Hello,
I am trying to use a nested BooleanQuery using the query "+text:jennifer
lopez" and I get no hits. If I use a simple Query it works fine and I get
the results I want.
I am using Lucene.Net 2.0.004 and I have looked in the tests. I have not
found any tests on phrases or wildcards using BooleanQuery. Does anybody
know if this is a known issue. Does anybody have a solution or a hint what I
could do to solve this problem.
I would be very pleased if someone had a solution for this.
Thanks!
Here is the code if somebody is interested:
IndexReader reader = IndexReader.Open("c:\temp\myIndex");
IndexSearcher searcher = new IndexSearcher(reader);
Analyzer analyzer = new StandardAnalyzer();
QueryParser parser = new QueryParser("text", analyzer);
BooleanQuery q1 = new BooleanQuery();
q1.Add(new TermQuery(new Term("text", "The text I want to search for")),
BooleanClause.Occur.MUST);
if (m_CatList.Count > 0) // It doesn't matter whether it enters this area or
not
{
BooleanQuery q2 = new BooleanQuery();
for (int i = 0; i < m_CatList.Count; i++)
{
q2.Add(new TermQuery(new Term("category", m_CatList[i].ToString())),
BooleanClause.Occur.SHOULD);
}
q1.Add(q2, BooleanClause.Occur.MUST);
}
m_Hits = searcher.Search(q1, s);