lucenenet-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Martin Nilsson" <>
Subject QueryParser vs own QueryBuilder
Date Sun, 10 Feb 2008 18:42:21 GMT

I'm struggling with a problem I can't solve. I create my Query object from
my own implemented query builder. However, I don't get any results back but
if I do a query.ToString and send it to the QueryParser I get result. Let me
show you some code.

//this doesn't return any results
//query.ToString() = "+category:general +product_type:1763 +title:\"shirt
brewality\" +country:2 +whitelabel:5 +price_type:1"
ISearchResult<ITinyItem> searchResult2 = searcher.Search(query);

//this returns 4 results
//query.Clone().ToString() = "+category:general +product_type:1763
+title:\"shirt brewality\" +country:2 +whitelabel:5 +price_type:1"
ISearchResult<ITinyItem> searchResult = searcher.Search(query.Clone

//this is called from query.Clone().ToString() above
public ISearchResult<T> Search(string searchTerms)
  if (string.IsNullOrEmpty(searchTerms)) throw new

  QueryParser parser = new QueryParser(defaultField, analyzer);
  Query query = parser.Parse(searchTerms);
  //the one that doesn't return any results calls below (Search(Query))
  //So the only, what I can see, difference is the code above in this
  return Search(query);

//and both are calling this
public ISearchResult<T> Search(Query query)
  //query.ToString() returns below result for BOTH, the one that returns 0
and the one that returns 4 result, queries
  //"+category:general +product_type:1763 +title:\"shirt brewality\"
+country:2 +whitelabel:5 +price_type:1"
  Hits hits = internalSearcher.Search(query);
  //code to create result

I have looked at the types of the underlying query and they are also the
same. BooleanQuery with 6 clauses where 5 are term queries and one, title,
is a phrase query. Looks the same both for my query and the one that
QueryParser.Parse creates.

I'm sooo confused! Please help!


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