Return-Path: Delivered-To: apmail-incubator-lucene-net-user-archive@locus.apache.org Received: (qmail 51127 invoked from network); 11 Feb 2008 14:56:38 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 11 Feb 2008 14:56:38 -0000 Received: (qmail 31990 invoked by uid 500); 11 Feb 2008 14:56:31 -0000 Delivered-To: apmail-incubator-lucene-net-user-archive@incubator.apache.org Received: (qmail 31971 invoked by uid 500); 11 Feb 2008 14:56:30 -0000 Mailing-List: contact lucene-net-user-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: lucene-net-user@incubator.apache.org Delivered-To: mailing list lucene-net-user@incubator.apache.org Received: (qmail 31961 invoked by uid 99); 11 Feb 2008 14:56:30 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 11 Feb 2008 06:56:30 -0800 X-ASF-Spam-Status: No, hits=-4.0 required=10.0 tests=RCVD_IN_DNSWL_MED,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [12.46.238.28] (HELO filter2.fishersci.com) (12.46.238.28) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 11 Feb 2008 14:56:00 +0000 Received: from ([10.0.20.38]) by filter2.fishersci.com with ESMTP id KP-BRAWP.211542932; Mon, 11 Feb 2008 09:54:35 -0500 Received: from uswal-mxrt02.amer.thermo.com ([10.210.1.136]) by PGHCR-EXBR-04.na.fshrnet.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 11 Feb 2008 09:54:35 -0500 Received: from USWAL-MXVS1.amer.thermo.com ([10.210.1.221]) by uswal-mxrt02.amer.thermo.com ([10.210.1.136]) with mapi; Mon, 11 Feb 2008 09:54:34 -0500 To: "lucene-net-user@incubator.apache.org" Date: Mon, 11 Feb 2008 09:54:33 -0500 Subject: RE: QueryParser vs own QueryBuilder Thread-Topic: QueryParser vs own QueryBuilder Thread-Index: AchsFMkR+B7RBg8DTf6ri2gwzQqscgAp7PeA Message-ID: <80CF7FF9C81BC64FB8453D113F49D22C0EA3D4F4E3@USWAL-MXVS1.amer.thermo.com> References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginalArrivalTime: 11 Feb 2008 14:54:35.0124 (UTC) FILETIME=[04447340:01C86CBE] From: "Granroth, Neal V." X-Virus-Checked: Checked by ClamAV on apache.org Martin, It is important to remember that Search(...) does not work from the text re= presentation of the Query object that you see when you use the ToString() m= ethod. 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 ToStrin= g(), which makes your two Query objects look identical even when they are n= ot. (For example, maybe your QueryBuilder is inserting a null Term that ca= uses 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 bo= th searches? -- Neal -----Original Message----- From: Martin Nilsson [mailto:mffmartin@gmail.com] Sent: Sunday, February 10, 2008 12:42 PM To: lucene-net-user@incubator.apache.org 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 m= e show you some code. //this doesn't return any results //query.ToString() =3D "+category:general +product_type:1763 +title:\"shirt brewality\" +country:2 +whitelabel:5 +price_type:1" ISearchResult searchResult2 =3D searcher.Search(query); //this returns 4 results //query.Clone().ToString() =3D "+category:general +product_type:1763 +title:\"shirt brewality\" +country:2 +whitelabel:5 +price_type:1" ISearchResult searchResult =3D searcher.Search(query.Clone ().ToString()); //this is called from query.Clone().ToString() above public ISearchResult Search(string searchTerms) { if (string.IsNullOrEmpty(searchTerms)) throw new ArgumentNullException("searchTerms"); QueryParser parser =3D new QueryParser(defaultField, analyzer); parser.SetFuzzyMinSim(fuzzyMinSimilarity); Query query =3D 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 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 =3D 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