From solr-user-return-146220-archive-asf-public=cust-asf.ponee.io@lucene.apache.org Fri Feb 8 06:28:12 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id A9ABC18060E for ; Fri, 8 Feb 2019 07:28:11 +0100 (CET) Received: (qmail 5789 invoked by uid 500); 8 Feb 2019 06:28:09 -0000 Mailing-List: contact solr-user-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: solr-user@lucene.apache.org Delivered-To: mailing list solr-user@lucene.apache.org Received: (qmail 5777 invoked by uid 99); 8 Feb 2019 06:28:08 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 08 Feb 2019 06:28:08 +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 5DB4818195B for ; Fri, 8 Feb 2019 06:28:08 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 4.486 X-Spam-Level: **** X-Spam-Status: No, score=4.486 tagged_above=-999 required=6.31 tests=[DKIM_ADSP_CUSTOM_MED=0.001, FORGED_GMAIL_RCVD=1, NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_PASS=-0.001, SPF_SOFTFAIL=0.972, URIBL_BLOCKED=0.001, URI_HEX=1.313] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id n0FsQZu4T3YI for ; Fri, 8 Feb 2019 06:28:07 +0000 (UTC) Received: from n3.nabble.com (n3.nabble.com [162.255.23.22]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id D88ED6243A for ; Fri, 8 Feb 2019 06:28:06 +0000 (UTC) Received: from n3.nabble.com (localhost [127.0.0.1]) by n3.nabble.com (Postfix) with ESMTP id EBEA411E337CF for ; Thu, 7 Feb 2019 23:28:05 -0700 (MST) Date: Thu, 7 Feb 2019 23:28:05 -0700 (MST) From: Jason To: solr-user@lucene.apache.org Message-ID: <1549607285963-0.post@n3.nabble.com> Subject: ValueSource with long BinaryField MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hi, I'm suffering from very long search response. Specifically, sort by ValueSource. I stored 4,096 length double array using BinaryField per a doc. In searching, I searched with sort function which is calculate a distance between two double array in custom defined ValueSource. But response time is too long. I think that both reading binary values and decoding base64 are too long. Is there a good solution to improve response time? Custom ValueSource snippet is below. public class VectorValueSource extends ValueSource { private final java.util.Base64.Decoder decoder = java.util.Base64.getDecoder(); public double distance(double[] qVector, double[] dVector) { double result = 0; for (int i = 0; i < qVector.length; i++) { double v = qVector[i] - dVector[i]; result += v * v; } return Math.sqrt(result); } @Override public FunctionValues getValues(Map context, LeafReaderContext readerContext) throws IOException { final FieldInfo fieldInfo = readerContext.reader().getFieldInfos().fieldInfo(field); if (fieldInfo != null && fieldInfo.getDocValuesType() == DocValuesType.BINARY) { final BinaryDocValues binaryValues = DocValues.getBinary(readerContext.reader(), field); final Bits docsWithField = DocValues.getDocsWithField(readerContext.reader(), field); return new FunctionValues() { @Override public double doubleVal(int doc) { BytesRef target = null; if (binaryValues.get(doc).length > 0) { target = binaryValues.get(doc); VectorUtils.byte2Double(decoder.decode(target.bytes), dFeature, false); return distance(qFeature, dFeature); } else { return maxDistance; } } }; } } } -- Sent from: http://lucene.472066.n3.nabble.com/Solr-User-f472068.html