Return-Path: X-Original-To: apmail-lucene-java-user-archive@www.apache.org Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 81EEC18B88 for ; Thu, 24 Dec 2015 13:50:40 +0000 (UTC) Received: (qmail 204 invoked by uid 500); 24 Dec 2015 13:50:36 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 147 invoked by uid 500); 24 Dec 2015 13:50:36 -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 135 invoked by uid 99); 24 Dec 2015 13:50:35 -0000 Received: from Unknown (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 24 Dec 2015 13:50:35 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 765FC18027C for ; Thu, 24 Dec 2015 13:50:35 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 2.879 X-Spam-Level: ** X-Spam-Status: No, score=2.879 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=3, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd3-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-eu-west.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id FXlFXzFYTCnE for ; Thu, 24 Dec 2015 13:50:34 +0000 (UTC) Received: from mail-lf0-f53.google.com (mail-lf0-f53.google.com [209.85.215.53]) by mx1-eu-west.apache.org (ASF Mail Server at mx1-eu-west.apache.org) with ESMTPS id F3AA02050F for ; Thu, 24 Dec 2015 13:50:33 +0000 (UTC) Received: by mail-lf0-f53.google.com with SMTP id l133so162489592lfd.2 for ; Thu, 24 Dec 2015 05:50:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :content-type; bh=beV4LOLWoKZDW+Xl4i7+NB/a5eLy+rHpRQYIercIswk=; b=MnAJOQ84OKr31QHV+STwGHRvCRgh6uzJPO5OarSJoMB2qNBjBtgB9Il+WWBsTPrg5i gGFiGeqX1CThn1zYM9KsMfBk+aalPjiIyvHj5dNzBm/bkrOUCuJ99q1noLBSvwjj15KS BhdIbVZA27/tyekVBPl/RIq9d27BWNKNf4HBMApP6diDNtjpIpWJoNsDIZIcWkx5a2h0 4s6eXcMakuSfQQe56qfM+EkVl5WyARD0FTXS3SeNdeYNS/PeQdnNrGVOT6fK+RYwor3o A8EVWUwcSw6ReTQVoRnTYBG7oXkaKwcdjVDDz5kaS7eW3uyu6NpVhI0u8rMh66Q8pbWt fdTQ== X-Received: by 10.25.84.72 with SMTP id i69mr11444591lfb.81.1450965026929; Thu, 24 Dec 2015 05:50:26 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Adrien Grand Date: Thu, 24 Dec 2015 13:50:17 +0000 Message-ID: Subject: Re: problem with payload retrieval in custom query - lucene 5.3.1 To: java-user@lucene.apache.org Content-Type: multipart/alternative; boundary=001a1141287203023f0527a51f2d --001a1141287203023f0527a51f2d Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Note that payloads are stored per position, not per document. Maybe the problem is that you never call docs.nextPosition()? Le mer. 23 d=C3=A9c. 2015 =C3=A0 19:30, Bob Price a = =C3=A9crit : > Via elasticsearch 2.1 we have written a custom Lucene TokenFilter that ad= ds > a payload to a special term during indexing analysis, and we also have > custom Lucene Query/Weight/Scorer classes that compare this payload again= st > some query data to decide if a document matches a query or not. > > I know that the payloads are being written as desired since I can easily > see them via elasticsearch's termvector API. > > However, while our Scorer can see all of the documents with this special > term, I can never get access to its payload. > > The approach to doing this in the Scorer is simply: > > docs =3D leafReaderContext.reader().postings(specialTerm, > PostingsEnum.PAYLOADS); > > Then, walking through the docs via nextDoc() and trying to retrieve each > doc's payload via: > > BytesRef payloadRef =3D docs.getPayload(); > if (payloadRef !=3D null) { > byte[] payload =3D payloadRef.bytes; > > } > > I have logging in place so that I see that every document I have in a tes= t > index is being looked at, but for every document, the payloadRef comes ba= ck > null. > > What am I doing wrong? Is there some setting I need to enable somewhere = to > allow the postings method to do what it says it can do? > > Is there a better way to do this? > > Any advice would be appreciated! > > Bob > --001a1141287203023f0527a51f2d--