Neal,
Thanks for your answer! I have also looked at the underlying types and
they look the same for both (QueryParser and QueryBuilder) queries.
But I only looked at the type of query and the term of the query. Is
there anything else I should look at?

The internalSearcher is the same, I'm sure.

"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."

My own Query Builder:
query.GetType().Name
"BooleanQuery"

((BooleanQuery) query).GetClauses()[0].GetQuery()
{category:general}
    [Lucene.Net.Search.TermQuery]: {category:general}

((BooleanQuery) query).GetClauses()[1].GetQuery()
{product_type:1763}
    [Lucene.Net.Search.TermQuery]: {product_type:1763}

((BooleanQuery) query).GetClauses()[2].GetQuery()
{title:"shirt brewality"}
    [Lucene.Net.Search.PhraseQuery]: {title:"shirt brewality"}

((BooleanQuery) query).GetClauses()[3].GetQuery()
{country:2}
    [Lucene.Net.Search.TermQuery]: {country:2}

((BooleanQuery) query).GetClauses()[4].GetQuery()
{whitelabel:5}
    [Lucene.Net.Search.TermQuery]: {whitelabel:5}

((BooleanQuery) query).GetClauses()[5].GetQuery()
{price_type:1}
    [Lucene.Net.Search.TermQuery]: {price_type:1}

QueryParser:
query.GetType().Name
"BooleanQuery"

((BooleanQuery) query).GetClauses()[0].GetQuery()
{category:general}
    [Lucene.Net.Search.TermQuery]: {category:general}

((BooleanQuery) query).GetClauses()[1].GetQuery()
{product_type:1763}
    [Lucene.Net.Search.TermQuery]: {product_type:1763}

((BooleanQuery) query).GetClauses()[2].GetQuery()
{title:"shirt brewality"}
    [Lucene.Net.Search.PhraseQuery]: {title:"shirt brewality"}

((BooleanQuery) query).GetClauses()[3].GetQuery()
{country:2}
    [Lucene.Net.Search.TermQuery]: {country:2}

((BooleanQuery) query).GetClauses()[4].GetQuery()
{whitelabel:5}
    [Lucene.Net.Search.TermQuery]: {whitelabel:5}

((BooleanQuery) query).GetClauses()[5].GetQuery()
{price_type:1}
    [Lucene.Net.Search.TermQuery]: {price_type:1}

On Feb 11, 2008 3:54 PM, Granroth, Neal V.
<[EMAIL PROTECTED]> wrote:
> Martin,
>
> It is important to remember that Search(...) does not work from the text 
> representation of the Query object that you see when you use the ToString() 
> method.  Instead it works from the type of objects of which the Query object 
> is composed and the clauses that join them together.
>
> It is entirely possible that there is a bug or operational quirk in 
> ToString(), which makes your two Query objects look identical even when they 
> are not.  (For example, maybe your QueryBuilder is inserting a null Term that 
> causes the search to fail, but that ToString() does not list since it is 
> null, meaningless, term.)
>
> Another possibility to look at is your "internalSearcher" object.  Are you 
> absolutely sure that it is being constructed in exactly the same way for both 
> searches?
>
> -- Neal
>
>
>
>
> -----Original Message-----
> From: Martin Nilsson [mailto:[EMAIL PROTECTED]
> Sent: Sunday, February 10, 2008 12:42 PM
> To: [email protected]
> Subject: QueryParser vs own QueryBuilder
>
> Hi,
>
> 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
> ().ToString());
>
> //this is called from query.Clone().ToString() above
> public ISearchResult<T> Search(string searchTerms)
> {
>  if (string.IsNullOrEmpty(searchTerms)) throw new
> ArgumentNullException("searchTerms");
>
>  QueryParser parser = new QueryParser(defaultField, analyzer);
>  parser.SetFuzzyMinSim(fuzzyMinSimilarity);
>  Query query = parser.Parse(searchTerms);
>  //the one that doesn't return any results calls below (Search(Query))
> directly.
>  //So the only, what I can see, difference is the code above in this
> function
>  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!
>
> Br,
> Martin
>

Reply via email to