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 0BF76200BEC for ; Thu, 29 Dec 2016 16:54:26 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 0A87F160B2D; Thu, 29 Dec 2016 15:54:26 +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 532D0160B15 for ; Thu, 29 Dec 2016 16:54:25 +0100 (CET) Received: (qmail 53041 invoked by uid 500); 29 Dec 2016 15:54:24 -0000 Mailing-List: contact user-help@lucenenet.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@lucenenet.apache.org Delivered-To: mailing list user@lucenenet.apache.org Received: (qmail 53029 invoked by uid 99); 29 Dec 2016 15:54:23 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 29 Dec 2016 15:54:23 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 794DAC0115 for ; Thu, 29 Dec 2016 15:54:23 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -0.321 X-Spam-Level: X-Spam-Status: No, score=-0.321 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_SORBS_SPAM=0.5, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd4-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 (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id G0iva1Y4tGV4 for ; Thu, 29 Dec 2016 15:54:21 +0000 (UTC) Received: from mail-qk0-f173.google.com (mail-qk0-f173.google.com [209.85.220.173]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id 23ED45F484 for ; Thu, 29 Dec 2016 15:54:21 +0000 (UTC) Received: by mail-qk0-f173.google.com with SMTP id t184so275229918qkd.0 for ; Thu, 29 Dec 2016 07:54:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=Osi6wWwFUNWcFQ+wjvZoPbOuLAgJpw+ca80OK2Bw7/Y=; b=GMxLRhJGWHUt1GeO0zpTT4WkZifzmRBQ00/nVs66iPINLXgg0BSko9VNCaBA254AJX i7BRt/MAGa6Yc1CrBonVInePLj4yaWhU7nQC0jVmlwcN0BrMeFUdkygClAdd4FyCBDu4 n31S79zebwM7XMUTSsQsvIOKLOOg4YMixGVEaexfws39FBxvPErFcz8K1sMEMiLM6oVN ZWlLLKR3x+x8nVrq7fprFvhQqTY9AEsemgrPRu/5VAb2p+SaaRHgAq5VBUNG5MSTyhdQ aBfRL35dUvse9qQcUpWgfAQ7coGF+D6of9y7qDeLYlyAIaZr50RbnrVzR2eZFJFpZvxt +faA== 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=Osi6wWwFUNWcFQ+wjvZoPbOuLAgJpw+ca80OK2Bw7/Y=; b=qLZhqpK14nXfb94nK609ez2ZM0Asle0LM6nbTiEYPpDcDRC2bdXd5IifnHjtsZ17Tg AZoGF88EnaTarOQOZipPESKDqfUCSco05p+eXH3h+saHEfzKt6FEq/XxWs4n5LVeGqMT SGAQ9QIbbBq9Ez6Ej/RetLHFTRFErK6jfhUHi5w3xFB92TkiUxno10VMZZ89V1ur9ewH aEcMGYMAHftl4R3s5pdWVChbT+vlHT0I/etKDkweL2+d9u8X2Xn/O/wDWgRVShJGH5do zF2XPLtQI+Zsn6qC0k9e95TyuFA41RgqTwk3GzQ57O8Oq86HzP6x9K0iNSDocSJBMuWg 7pyQ== X-Gm-Message-State: AIkVDXIExIuIVD2wltB7Jy+e9dKBm3NPt+p45fkFbYFBE6KMYN5lIzvJFRdrGwTh8pOvANHQmt63c0csO7bCsw== X-Received: by 10.55.151.65 with SMTP id z62mr45724237qkd.180.1483026854607; Thu, 29 Dec 2016 07:54:14 -0800 (PST) MIME-Version: 1.0 Received: by 10.237.52.37 with HTTP; Thu, 29 Dec 2016 07:53:54 -0800 (PST) In-Reply-To: References: From: "Koga, Diego" Date: Thu, 29 Dec 2016 10:53:54 -0500 Message-ID: Subject: Re: Facet Performance To: user@lucenenet.apache.org Content-Type: text/plain; charset=UTF-8 archived-at: Thu, 29 Dec 2016 15:54:26 -0000 Hi all, I figured something out. Once I keep the reader and searcher as singleton, I also need to keep the facet engine. However, the SimpleFacetedSearch was consuming huge amount of memory, the SparseFacetedSearcher is way more memory optimized. I am creating one for each facet that I have and while searching, I pick the right facet searcher to use. This is how my code looks like: private void CreateReader() { if (_indexReader == null) { var dir = FSDirectory.Open(IndexDirectories.WorkDirectory); if (!IndexReader.IndexExists(dir)) { dir.Dispose(); throw new FileNotFoundException( "Index not found. Before initialize the reader, make sure to create the index."); } _indexReader = IndexReader.Open(dir, true); _indexSeacher = new IndexSearcher(_indexReader); _facetsSearchers = CreateFacetsSearchers(dir); } } private Dictionary CreateFacetsSearchers(FSDirectory directory) { var facetReaders = new Dictionary(); foreach (var facet in AvailableFacets.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) { var indexReader = IndexReader.Open(directory, true); var facetSeacher = new SparseFacetedSearcher(indexReader, facet); facetReaders.Add(facet, facetSeacher); } return facetReaders; } Att., ------------------ Koga, Diego On Mon, Dec 26, 2016 at 6:05 PM, Koga, Diego wrote: > Guys, Happy Holidays!!! > > I am tunning an existing Lucene.Net index where I am currently working. > > The perfomance was greatly increase when we talk about the search itself. > > But when it goes to facet concern, I'm getting crazy! > > This is the scenario: > > - 1.8M products on a SQL Server. > - Basically we concatenate all analyzed fields into one. (made the search > work way better) > - Create a specific price field to set a price range in order to group later > in a facet. (here we have ranges configured in the system that we save only > the id. The ideia is to minimize the number of possible facets) > - 16k categories (maybe I can do a tree here and minimize it too, need > opinions) > - 2k manufacturers > - Facets needed: On Sale (boolean), Review (0 - 5), Price (let's say 10 > ranges), Free Shipping (boolean), Manufacturer (string) and Category > (string). > > Question 1: What do you guys would improve when writing the index? > > The lucene is embedded in ASP.NET app where the clients make a REST http > request. It's only one request that returns the result of the search and > also the facets. To make it faster, I am processing the search and each > facet in parallel. Which also make the search waits for the facets until > it's done (I figured out that is faster process in parallel than pass an > array). > > This is the facet search: > > using (var simpleFacetedSearch = new > SimpleFacetedSearch(_indexReader, facetName)) > { > var hits = simpleFacetedSearch.Search(query, 1); > return hits; > } > > Question 2: What do you guys recommend to make this search faster and also > does not freeze the server because high memory usage? > > > Thanks.... > > > Att., > ------------------ > Koga, Diego > >> >