From solr-user-return-148286-archive-asf-public=cust-asf.ponee.io@lucene.apache.org Fri Jun 7 13:52:38 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 [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id 63C5C18067E for ; Fri, 7 Jun 2019 15:52:38 +0200 (CEST) Received: (qmail 33835 invoked by uid 500); 7 Jun 2019 13:51:22 -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 32113 invoked by uid 99); 7 Jun 2019 13:50:51 -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, 07 Jun 2019 13:50:51 +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 073CA180A39 for ; Fri, 7 Jun 2019 13:50:51 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 2.002 X-Spam-Level: ** X-Spam-Status: No, score=2.002 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HTML_MESSAGE=2, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001] autolearn=disabled Authentication-Results: spamd3-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=sease-io.20150623.gappssmtp.com 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 X-rxGpjL5VnE for ; Fri, 7 Jun 2019 13:50:49 +0000 (UTC) Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTPS id BA7CF5F382 for ; Fri, 7 Jun 2019 13:50:48 +0000 (UTC) Received: by mail-wm1-f65.google.com with SMTP id t5so2007150wmh.3 for ; Fri, 07 Jun 2019 06:50:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sease-io.20150623.gappssmtp.com; s=20150623; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language; bh=80VVvbOBMMDw7OO5myMPGt1gn86fwsLV9NB5X6QPXZU=; b=ZfvgFJLnlkNKnZmsLViW5VUwvt+2tWhNFEyRzw+DggKDD/a9QRHgoW24wzRmqC/8Dg Mw7FxkLvADgMXyBfgwHKi7sAmfbPU+ga/PwR7RiP1kgglQcowvcoKT2NSluQRmLQeOmW icBkwyYQ0yOlJtLtIopxzaX51ML5Szu2tBDtnKk3aOQgvgCUMkNpHhPjYcG+6ci1iDFM HYeF0DyfJQRNgNMI2FTrtoxSOpR7P2onyOcPya0ECSeHyz3Yx13ellezw6c6MC1CN+ao 27monjP4HiKiq4sYrCmRv4HXEhX8ZOa0hYgimvBT5vFwSjKlPmnzoKxtpIDEYWVOP3ZX 2gzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=80VVvbOBMMDw7OO5myMPGt1gn86fwsLV9NB5X6QPXZU=; b=Y89XqPGEzbwFRgc8Mf2B1LMIK5sEYX0IEKVPkxeNfb7p/g4uPOQE3T5UjWKvuiaD7I wwSW6PemBajRqvfHBw2vUgfKJRJx2HHxw7iVQb9PGKAE5djnHUWZEwWN9o4zLv5kpqF8 tr6zzayzXXr1JV+daRkoC8A2ZIFHkGasrzxxvLnbGs7shlvmRtmnnIgYjRqsrYGrcpB+ 9mnRJDO89TcjQoi01u4nuDDpMdLqXRAPjtEy7gwhndtUdMo0WxmLEg88LilxR4VNPL2x UDGi0+yap46IaolcizQ1SbOkSm4nyQevQsCRRQIw6xRSj2WgYw8cuqSkhI3V9xqivQUF o3JA== X-Gm-Message-State: APjAAAVn+BqV7tL+g/ZE1P0N4l1EH6N83TuwFtP1Zz6jMzAXvgafZn2e rbzHY8vJdkpArhjTuuydBBnu1/8dMt/umA== X-Google-Smtp-Source: APXvYqzZ0v7N/CvTHe07R3uXAwTmFkwGFecHvaig6Dy3JIm9fMUUl8U4JBWoQSC6mmbYLebSVOUT3Q== X-Received: by 2002:a1c:e90f:: with SMTP id q15mr4006269wmc.89.1559915442274; Fri, 07 Jun 2019 06:50:42 -0700 (PDT) Received: from [192.168.1.7] ([95.235.250.64]) by smtp.gmail.com with ESMTPSA id a125sm2289397wmf.42.2019.06.07.06.50.41 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 07 Jun 2019 06:50:41 -0700 (PDT) Subject: Re: searching only within a date range To: solr-user@lucene.apache.org References: From: Andrea Gazzarini Message-ID: Date: Fri, 7 Jun 2019 15:50:37 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------569321C54A255839BFB96C8F" Content-Language: en-US --------------569321C54A255839BFB96C8F Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Hi Mark, you are using a "range facet" which is a "query-shape" feature, it doesn't have any constraint on the results (i.e. it doesn't filter at all). You need to add a filter query [1] with a date range clause (e.g. fq=field:[ TO ]). Best, Andrea [1] https://lucene.apache.org/solr/guide/6_6/common-query-parameters.html#CommonQueryParameters-Thefq_FilterQuery_Parameter [2] https://lucene.apache.org/solr/guide/6_6/working-with-dates.html On 07/06/2019 14:02, Mark Fenbers - NOAA Federal wrote: > Hello! > > I have a search setup and it works fine. I search a text field called > "logtext" in a database table. My Java code is like this: > > SolrQuery query - new SolrQuery(); > query.setQuery(searchWord); > query.setParam("df", "logtext"); > > Then I execute the search... and it works just great. But now I want to > add a constraint to only search for the "searchWord" within a certain range > of time -- given timestamps in the column called "posttime". So, I added > the code in bold below: > > SolrQuery query - new SolrQuery(); > query.setQuery(searchWord); > *query.setFacet(true);* > *query.addDateRangeFacet("posttime", new Date(System.currentTimeMillis() - > 1000L * 86400L * 365L), new Date(System.currentTimeMillis()), "+1DAY"); /* > from 1 year ago to present) */* > query.setParam("df", "logtext"); > > But this gives me a complaint: *undefined field: "posttime"* so I clearly > do not understand the arguments needed to addDateRangeFacet(). Can someone > help me determine the proper code for doing what I want? > > Further, I am puzzled about the "gap" argument [last one in > addDateRangeFacet()]. What does this do? I used +1DAY, but I really have > no idea the purpose of this. I haven't found any documentation that > explains this well. > > Mark > --------------569321C54A255839BFB96C8F--