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 EA3FE200D50 for ; Mon, 4 Dec 2017 11:10:32 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id E7278160C05; Mon, 4 Dec 2017 10:10:32 +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 38E3B160BF9 for ; Mon, 4 Dec 2017 11:10:32 +0100 (CET) Received: (qmail 30880 invoked by uid 500); 4 Dec 2017 10:10:30 -0000 Mailing-List: contact java-user-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: java-user@lucene.apache.org Delivered-To: mailing list java-user@lucene.apache.org Received: (qmail 30868 invoked by uid 99); 4 Dec 2017 10:10:30 -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; Mon, 04 Dec 2017 10:10:30 +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 A16891A003E for ; Mon, 4 Dec 2017 10:10:29 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.28 X-Spam-Level: * X-Spam-Status: No, score=1.28 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HTML_MESSAGE=2, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01] autolearn=disabled Authentication-Results: spamd2-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=detectum-com.20150623.gappssmtp.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 eXLWzYjyiIZO for ; Mon, 4 Dec 2017 10:10:27 +0000 (UTC) Received: from mail-qt0-f181.google.com (mail-qt0-f181.google.com [209.85.216.181]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id 475C45F2A9 for ; Mon, 4 Dec 2017 10:10:27 +0000 (UTC) Received: by mail-qt0-f181.google.com with SMTP id d15so20444579qte.4 for ; Mon, 04 Dec 2017 02:10:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=detectum-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=Yacti+ep1CHzgdMeJ3r4HAt6bqgCTT8LqD9tzz/refE=; b=ZP8SnYu8mgw/41SyTFHOkaG/sRRHGbhvtTGbuE722df4BnzRd5JDtJAXsgui1x6SJr hQQZIs3QVhSI4J0A5UWshmdzSVQ+O0FLFRn2C++Ra+XMyovjMe8U//YkMRinwvigvlAO LaUGFYbNBIWsyWc8dnCv47WHOHn5GqxL9LJcbKeKqKJinuh0rQT8qNKR+ogkC1GYsguQ q8IdmnetqC2Q8yCEscP8FbnlHJGc9I4fM8xxYFyN7uJcFBKQXwj10YseasOjt2Jt7ptQ gz6G/owuBN2QCWGlMJ28qFnxv8K869sfTnOgtYpzmEqqfGbyXmJqdmEin8AtaMN04NTU 2Dfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=Yacti+ep1CHzgdMeJ3r4HAt6bqgCTT8LqD9tzz/refE=; b=s9Z1m8kUVE5FUyYt+aNpVuqgtrL7G656TevoNdeBA97E6Tzijc9EteOX6AZWq8IUKl 7Nwql0S0nQ3aHMIplWixkR8rntyIAw9Byj9jKwDLW5Goo5SacGsmKMpK0IpMhIT2WkCY TsqYjr/A01h4iOdaQA0xobpvKU25TXulxlymjDIMka4QM3yFKNybNllMfjCE08JyY7gd fOzaY/EUEgnXvgD9cpfW5Nv+DuQAoz0ZxC8MhXptUShwhNcTIiQ8Ui6fqTWskz11+S7q B/0WV9wd8THxDR+HhHjs01R+jHfhTqYCuzcd/mhGmliFIFzfSM6Vkftekq3U7JFEzdMi DM6Q== X-Gm-Message-State: AKGB3mKz/An0ywQUdhZqATlGsNK3JIGNtvWZWglhU6P52sSNNNXS1WCE bBjm/ieNgeDLpvTEe2d2+7rMVvbdOGkJCBrXSfDIu4DA7k8= X-Google-Smtp-Source: AGs4zMYUC3ThLu1KHD7ImohT5qAh7W+cUR040eYyeWFAePEqcJMr/VynZMLWVPUIA1oOwAPH9FMXG+4FnULd1CI0eVw= X-Received: by 10.200.55.121 with SMTP id p54mr20745304qtb.332.1512382226748; Mon, 04 Dec 2017 02:10:26 -0800 (PST) MIME-Version: 1.0 Received: by 10.140.88.16 with HTTP; Mon, 4 Dec 2017 02:10:26 -0800 (PST) In-Reply-To: References: From: Vadim Gindin Date: Mon, 4 Dec 2017 15:10:26 +0500 Message-ID: Subject: Re: Scorer.iterator() - how to implement correctly To: java-user@lucene.apache.org Content-Type: multipart/alternative; boundary="001a113b8a2a63f383055f80eddf" archived-at: Mon, 04 Dec 2017 10:10:33 -0000 --001a113b8a2a63f383055f80eddf Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Adrien. I've found some working solution. Here is how it calculates iterator: this.iterator =3D context.reader().postings(query.getTerm(), PostingsEnum.A= LL); if (this.iterator =3D=3D null) this.iterator =3D DocIdSetIterator.empty(); Is that implementation correct? On Sun, Dec 3, 2017 at 4:43 PM, Vadim Gindin wrote: > Hi Adrien. > > ConstantScoreQuery - I'd tried that earlier. There is the problem. It > returns score =3D 0.0 for my configuration with Boolean.. I've debugged a= nd > found, that it happens because of the following: > > @Override > public Weight createWeight(IndexSearcher searcher, boolean needsScores, f= loat boost) throws IOException { > final Weight innerWeight =3D searcher.createWeight(query, false, 1f); > if (needsScores) { > return new ConstantScoreWeight(this, boost) { > > > As you can see innerWeight is created with needsScores=3Dfalse and furth= er > innerWeight.scorerSuplier will return null. That will lead to 0.0 final > score. > > Moreover I'm trying to start my current logic from simple step. That's wh= y > I wanted to implement something simple and decide to write it from scratc= h. > > Ok, as you say - iterator is the reason of returning all documents. *So > how to properly implement scorer.iterator()?* > > Many thanks for your help! > Regards > Vadim Gindin > > On Fri, Dec 1, 2017 at 1:11 PM, Adrien Grand wrote: > >> There are many implementations because each query typically needs a cust= om >> DocIdSetIterator implementation. It looks like your use-case doesn't nee= d >> a >> custom query though, you could use a TermQuery wrapped in a constant-sco= re >> query (see my reply to the other question you asked). >> >> Le ven. 1 d=C3=A9c. 2017 =C3=A0 08:24, Vadim Gindin a =C3=A9crit >> : >> >> > Hi >> > >> > I'm implementing the custom QUERY with appropriate custom WEIGHT and >> > SCORER. >> > >> > I'm trying to implement Scorer.iterator() method. It should return an >> > iterator of documents that matches the query. Right? There are a lot o= f >> > descendant classes of the DocIdSetIterato. >> > >> > 1. How to choose correct one? >> > 2. How to correctly implement Scorer.iterator() method? >> > >> > I've tried DocIdSetIterator.all(context.reader().maxDoc()); >> > >> > But as I can see it returns all documents. >> > >> > My task looks simple. I need to return a constant score depending on t= he >> > matched fields. I.e. field "model" score - 3f, field "vendor" - score = - >> 5f. >> > >> > I'm creating a subquery for each field and specify score for it using >> > custom QUERY that is almost the same as TermQuery except Weight.Scorer >> > >> > Any help is appreciated. >> > >> > Regards, >> > Vadim Gindin >> > >> > > --001a113b8a2a63f383055f80eddf--