Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id EB22F200BCE for ; Fri, 2 Dec 2016 08:26:15 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id E9E98160B24; Fri, 2 Dec 2016 07:26:15 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 3E61B160B16 for ; Fri, 2 Dec 2016 08:26:15 +0100 (CET) Received: (qmail 99924 invoked by uid 500); 2 Dec 2016 07:26:14 -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 99911 invoked by uid 99); 2 Dec 2016 07:26:13 -0000 Received: from mail-relay.apache.org (HELO mail-relay.apache.org) (140.211.11.15) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 02 Dec 2016 07:26:13 +0000 Received: from mail-wj0-f181.google.com (mail-wj0-f181.google.com [209.85.210.181]) by mail-relay.apache.org (ASF Mail Server at mail-relay.apache.org) with ESMTPSA id 341501A0044 for ; Fri, 2 Dec 2016 07:26:13 +0000 (UTC) Received: by mail-wj0-f181.google.com with SMTP id qp4so224500485wjc.3 for ; Thu, 01 Dec 2016 23:26:13 -0800 (PST) X-Gm-Message-State: AKaTC02xFY8vJJK00T3WYmYNeqmALSMKo6WA/CGrCpPXgXMOk4BVkvTg7QtiIpixmN8DD7fPcazjFoaVz1cXuQ== X-Received: by 10.194.22.41 with SMTP id a9mr15402279wjf.30.1480663571876; Thu, 01 Dec 2016 23:26:11 -0800 (PST) MIME-Version: 1.0 Received: by 10.194.81.170 with HTTP; Thu, 1 Dec 2016 23:26:11 -0800 (PST) In-Reply-To: References: From: Mikhail Khludnev Date: Fri, 2 Dec 2016 10:26:11 +0300 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: Lucene filter To: general@lucene.apache.org Content-Type: multipart/alternative; boundary=047d7b5d86953bd4150542a7dab7 archived-at: Fri, 02 Dec 2016 07:26:16 -0000 --047d7b5d86953bd4150542a7dab7 Content-Type: text/plain; charset=UTF-8 Hello, I don't think # is supported in query parsers, although it would be great. So, far I saw them in only in toString(). On Fri, Dec 2, 2016 at 9:30 AM, Bouadjenek mohamed reda < redateksystem@gmail.com> wrote: > Hi All, > > > I wanna use a filter into a query (BooleanClause.Occur.FILTER). For > example, my query is: > > #repository:clinicaltrials +title:multipl > > 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? > > Example 1: > String query = "#repository:clinicaltrials +title:multipl"; > QueryParser qr = new QueryParser("", new StandardAnalyzer()); > TopDocs hits = is.search(qr.parse(query), 1); > > Example 2: > String[] fields = new String[]{"repository", "title"}; > BooleanClause.Occur[] allflags = new > BooleanClause.Occur[]{BooleanClause.Occur.FILTER, > BooleanClause.Occur.MUST}; > String[] query_text = new String[]{"clinicaltrials", "multipl"}; > Query finalQuery = MultiFieldQueryParser.parse(query_text, fields, > allflags, new StandardAnalyzer()); > TopDocs hits = is.search(finalQuery, 1); > > > thanks, > > > Best, > reda > -- Sincerely yours Mikhail Khludnev --047d7b5d86953bd4150542a7dab7--