From general-return-4874-apmail-lucene-general-archive=lucene.apache.org@lucene.apache.org Fri Dec 2 08:41:35 2016 Return-Path: X-Original-To: apmail-lucene-general-archive@www.apache.org Delivered-To: apmail-lucene-general-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id ED6A019F84 for ; Fri, 2 Dec 2016 08:41:35 +0000 (UTC) Received: (qmail 72071 invoked by uid 500); 2 Dec 2016 08:41:35 -0000 Delivered-To: apmail-lucene-general-archive@lucene.apache.org Received: (qmail 72019 invoked by uid 500); 2 Dec 2016 08:41:35 -0000 Mailing-List: contact general-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: general@lucene.apache.org Delivered-To: mailing list general@lucene.apache.org Received: (qmail 72003 invoked by uid 99); 2 Dec 2016 08:41:35 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 02 Dec 2016 08:41:35 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 9AAF41AA2A8 for ; Fri, 2 Dec 2016 08:41:34 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -0.102 X-Spam-Level: X-Spam-Status: No, score=-0.102 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd2-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id zGC7f_E0hAzG for ; Fri, 2 Dec 2016 08:41:32 +0000 (UTC) Received: from mail-pg0-f43.google.com (mail-pg0-f43.google.com [74.125.83.43]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id 48A1B5F1F0 for ; Fri, 2 Dec 2016 08:41:32 +0000 (UTC) Received: by mail-pg0-f43.google.com with SMTP id 3so105345885pgd.0 for ; Fri, 02 Dec 2016 00:41:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:content-transfer-encoding:mime-version:subject:date:references :to:in-reply-to:message-id; bh=sKWvD6xx6KePscqmqh1if+Ori2Z/hIX/cXMc+GU3U5U=; b=HDY2Y14zvJ0UfFHeZ/aov3ERLkKyUyymeC6vVsqqnRd+b+bmje2SzvqJ2WOKG+SClv C0z8872E/vXtrZCFIcRHpx7glxA1jtl4B5VEGUTjY+MK7S27eNtdSo+yFHx8CnvzgPUp 1PL6mQN7UrcPM+pW/ysLD0cf41rjtSnYC/e+v8yBHMT9EN0dQN+JnTL8ZLBSbkBlHNQJ 9DLp3TDIdd/h4iS5u+yse+Q74ientehPyyZuJVEx3m4ONETIxJ84S8OHHi6amshQAC+C N8znAN//V7vbN3vTzW6XxMhu9gB7eY8dxyBVsLzBCsaqXTVM8Z0YbbT37c7g6KteMpEX ek8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:content-transfer-encoding:mime-version :subject:date:references:to:in-reply-to:message-id; bh=sKWvD6xx6KePscqmqh1if+Ori2Z/hIX/cXMc+GU3U5U=; b=ASeR0QrZwNj9rYQ3MqUp2g3AZMVh3JzBOJ/W9xTxvEa/zL3hZHWBXVKoCFeasmA/Tm hEi3s0A7LUcW44/QqJ2NaQ2pgKelAOiovEfHM8sqXrmCb1BNqZRTIgudz3t9ednPIVSb B2h+CcjP6r1atVWG0ZOaLnZSonXdRVFrMfotwO1Exc4y5NeVOWZYQUVtw4SOOG/N9/RC OnTWXXcoNBR03w5mEU1V/GjlqEmkvbR9tUDhLOzifcnJCB7BPgxN5Xkmy9HYwWtkm2Ag GGs3z5DrJKsMoPe7ai+vTQUApLOviTz5M3/VCvQxnx+i1jZVWaTCPspJlQGReYsdzMm3 ROWg== X-Gm-Message-State: AKaTC011qCdow0Fx8WUvI8DBDn4OI9iTJXeroQDatvaCuxSOTh526Poqxh4whbRjBS/7pg== X-Received: by 10.84.218.79 with SMTP id f15mr93702833plm.155.1480668091290; Fri, 02 Dec 2016 00:41:31 -0800 (PST) Received: from [192.168.1.3] (118.138.240.116.sta.dodo.net.au. [116.240.138.118]) by smtp.gmail.com with ESMTPSA id n25sm5686814pfi.33.2016.12.02.00.41.29 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Dec 2016 00:41:30 -0800 (PST) From: Reda Kouba Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 10.1 \(3251\)) Subject: Re: Lucene filter Date: Fri, 2 Dec 2016 19:41:27 +1100 References: <1103E3B8-B42F-47F4-99FB-ED2064D0AB9B@gmail.com> <007901d24c77$7aa441d0$6fecc570$@thetaphi.de> To: general@lucene.apache.org In-Reply-To: <007901d24c77$7aa441d0$6fecc570$@thetaphi.de> Message-Id: <98B93881-2C3B-449D-AC9A-18F17DD0560A@gmail.com> X-Mailer: Apple Mail (2.3251) Hi Uwe, Thank you for your suggestion. In fact, it=E2=80=99s for an IR = challenge. No intent to use my code for end-users. best, reda > On 2 Dec. 2016, at 19:38, Uwe Schindler wrote: >=20 > Hi, >=20 > You could use 2 query parsers, e.g., one for the user input and = another one for the filters. Finally combine the 2 results into one = query by combining them with an outer BooleanQuery. Having everything in = one single string is quite uncommon for typical search application = logic. >=20 > Uwe >=20 > ----- > Uwe Schindler > Achterdiek 19, D-28357 Bremen > http://www.thetaphi.de > eMail: uwe@thetaphi.de >=20 >> -----Original Message----- >> From: Reda Kouba [mailto:redateksystem@gmail.com] >> Sent: Friday, December 2, 2016 8:33 AM >> To: general@lucene.apache.org >> Subject: Re: Lucene filter >>=20 >> Hi Mikhail, >>=20 >> Do you have any suggestion to transform a string to a query object? >> thanks, >> reda >>=20 >>=20 >>> On 2 Dec. 2016, at 18:26, Mikhail Khludnev wrote: >>>=20 >>> Hello, >>>=20 >>> I don't think # is supported in query parsers, although it would be = great. >>> So, far I saw them in only in toString(). >>>=20 >>> On Fri, Dec 2, 2016 at 9:30 AM, Bouadjenek mohamed reda < >>> redateksystem@gmail.com> wrote: >>>=20 >>>> Hi All, >>>>=20 >>>>=20 >>>> I wanna use a filter into a query (BooleanClause.Occur.FILTER). For >>>> example, my query is: >>>>=20 >>>> #repository:clinicaltrials +title:multipl >>>>=20 >>>> It looks like when I build the query from this String, the filter = is not >>>> working. In other words, the total hits in the first example below = is >>>> different from total hits in the second example below. Please, does >> anyone >>>> know what wrong with this simple example? >>>>=20 >>>> Example 1: >>>> String query =3D "#repository:clinicaltrials +title:multipl"; >>>> QueryParser qr =3D new QueryParser("", new StandardAnalyzer()); >>>> TopDocs hits =3D is.search(qr.parse(query), 1); >>>>=20 >>>> Example 2: >>>> String[] fields =3D new String[]{"repository", "title"}; >>>> BooleanClause.Occur[] allflags =3D new >>>> BooleanClause.Occur[]{BooleanClause.Occur.FILTER, >>>> BooleanClause.Occur.MUST}; >>>> String[] query_text =3D new String[]{"clinicaltrials", "multipl"}; >>>> Query finalQuery =3D MultiFieldQueryParser.parse(query_text, = fields, >>>> allflags, new StandardAnalyzer()); >>>> TopDocs hits =3D is.search(finalQuery, 1); >>>>=20 >>>>=20 >>>> thanks, >>>>=20 >>>>=20 >>>> Best, >>>> reda >>>>=20 >>>=20 >>>=20 >>>=20 >>> -- >>> Sincerely yours >>> Mikhail Khludnev >=20