From solr-user-return-119415-apmail-lucene-solr-user-archive=lucene.apache.org@lucene.apache.org Sat Jan 2 02:16:00 2016 Return-Path: X-Original-To: apmail-lucene-solr-user-archive@minotaur.apache.org Delivered-To: apmail-lucene-solr-user-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 638DC182BE for ; Sat, 2 Jan 2016 02:16:00 +0000 (UTC) Received: (qmail 69719 invoked by uid 500); 2 Jan 2016 02:15:56 -0000 Delivered-To: apmail-lucene-solr-user-archive@lucene.apache.org Received: (qmail 69648 invoked by uid 500); 2 Jan 2016 02:15:56 -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 69636 invoked by uid 99); 2 Jan 2016 02:15:55 -0000 Received: from Unknown (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 02 Jan 2016 02:15:55 +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 79DD118028B for ; Sat, 2 Jan 2016 02:15:55 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 2.881 X-Spam-Level: ** X-Spam-Status: No, score=2.881 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, URIBL_BLOCKED=0.001, WEIRD_PORT=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-us-east.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id 8CThjUrpMUi6 for ; Sat, 2 Jan 2016 02:15:49 +0000 (UTC) Received: from mail-yk0-f170.google.com (mail-yk0-f170.google.com [209.85.160.170]) by mx1-us-east.apache.org (ASF Mail Server at mx1-us-east.apache.org) with ESMTPS id 0AE1542ADC for ; Sat, 2 Jan 2016 02:15:49 +0000 (UTC) Received: by mail-yk0-f170.google.com with SMTP id x67so204998258ykd.2 for ; Fri, 01 Jan 2016 18:15:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=z91g1TwuUBATu7xBPXpsO6PXDlUQwm2F7JUHizWRRFM=; b=aVOKnKbhEtogf5XIG/kohzIG3ccZD1fam6q/ixy1aKSGkgeMpJks9J8KRcZtRYEW8N d6POV06sdsnoub29DAsK9nih8es+cvCtmISa7ZFY64uEx220c7PAg5sUoae3l7/eQAIi v5e6fUUsh/Nt+NfK2CuvJqMJ/r5PF4vM7wxMvfgYZQCOe256yhjK8XzH92OA4BzZYv6K JtrTDp9dtad3OiaAMUBi8tvpjclfNkUdS3hnlHo5h3aM5SGmFUW5QLMLqMkxxWCZsVfy a30q32vunfk4vJdRL4xnJ+24NlyVMI7HmhBWAQnVk+qRmtQupYTaVIr43TItx6Rqm4yw 5KIw== MIME-Version: 1.0 X-Received: by 10.129.17.142 with SMTP id 136mr20095484ywr.109.1451700948547; Fri, 01 Jan 2016 18:15:48 -0800 (PST) Received: by 10.129.145.75 with HTTP; Fri, 1 Jan 2016 18:15:48 -0800 (PST) In-Reply-To: <1451686118.4116104.480686570.3FC0E109@webmail.messagingengine.com> References: <1451679343.4095886.480639330.30B1020E@webmail.messagingengine.com> <1451686118.4116104.480686570.3FC0E109@webmail.messagingengine.com> Date: Fri, 1 Jan 2016 19:15:48 -0700 Message-ID: Subject: Re: Issue with if() statement From: William Bell To: "solr-user@lucene.apache.org" Content-Type: multipart/alternative; boundary=001a1142cc365bc41405285077c3 --001a1142cc365bc41405285077c3 Content-Type: text/plain; charset=UTF-8 Sample code for a simple query parser? On Fri, Jan 1, 2016 at 3:08 PM, Upayavira wrote: > You've got to think of what the queries will be that you produce under > the bonnet - what you are talking about is either a (!func} or a > {!frange} query - both of which are inefficient as they must scan the > entire resultset. > > However, what you're trying to do is evaluate the length of the *input > value*, not a value in the documents being searched, so this doesn't > really apply - you're talking about doing some work before your query > happens. > > Again, I'm not sure of a way to do this on a stock Solr, but with a > little coding it should be achievable - you could extend the switch > query parser, or you could write your own - they're not that hard to > create. Or, you could create a search component that operates before the > QueryComponent does. > > A simple queryparser of your own would seem like a pretty lightweight > thing - probably 20 lines of code or less. > > Upayavira > > On Fri, Jan 1, 2016, at 09:40 PM, William Bell wrote: > > Forgot last bit: > > > > fq={!switch case.gt.0=$state1 > > default=$state > > func=len($state1)} > > > > > > On Fri, Jan 1, 2016 at 2:39 PM, William Bell > wrote: > > > > > Maybe we can add function value on a switch? > > > > > > fq={!switch case.gt.0 > > > default=$state > > > func=len($state1)} > > > > > > > > > > > > We could add: gt, lt, eq, ge, le ? > > > > > > gt: greater than > > > lt: less than > > > eq: equal > > > ge: greater than or equal > > > le: less than or equal > > > > > > ?? > > > > > > > > > > > > On Fri, Jan 1, 2016 at 2:25 PM, William Bell > wrote: > > > > > >> This all started with me trying to use {!switch} to indicate with CO > or > > >> NY to use. if we pass state1, that is supposed to take precedence, > but if > > >> nothing is returned, then use state.... Make sense now? > > >> > > >> I could not find a way to check for strlen($state1). Which is what I > want > > >> in the case statement. This just does not work... > > >> Something like the following is what I am trying to do: > > >> > > >> > > >> fq={!switch case."anything"=$state1 > > >> default=$state > > >> v=$state1} > > >> > > >> So I tried the following to set all 50 states: > > >> > > >> > > >> fq={!switch case.all='*:*' > > >> case.CO='state:CO' > > >> case.NY='state:NY' > > >> v=$state1} > > >> > > >> > > >> Obviously Oregon (OR!) is an issue, and it won't work at all plus > > >> > > >> > > >> > > >> On Fri, Jan 1, 2016 at 2:15 PM, William Bell > wrote: > > >> > > >>> Another weirdness: > > >>> > > >>> > > >>> > http://localhost:8983/solr/providersearch/select?wt=json&state=state:CO&state1=state:NY&fl=*&q=*:*&tt=$state1&fq={!lucene%20v=$tt} > > >>> < > http://localhost:8983/solr/providersearch/select?wt=json&state=state:CO&state1=state:NY&fl=*&q=*:*&tt=$state1&fq=%7B!lucene%20v=$tt%7D > > > > >>> > > >>> That does not return anything. > > >>> > > >>> But if I set v=$state1 I get results. > > >>> > > >>> Can I not set equivalent variables? > > >>> > > >>> > > >>> > > >>> On Fri, Jan 1, 2016 at 2:07 PM, William Bell > > >>> wrote: > > >>> > > >>>> Example. > > >>>> > > >>>> > > >>>> > http://localhost:8983/solr/providersearch/select?wt=json&state=state:%22CO%22&state1=state:%22NY%22&fl=ss,score&q=*:*&fq={!lucene%20v=$state1} > > >>>> < > http://localhost:8983/solr/providersearch/select?wt=json&state=state:%22CO%22&state1=state:%22NY%22&fl=ss,score&q=*:*&fq=%7B!lucene%20v=$state1%7D > > > > >>>> > > >>>> This return 236,000 > > >>>> > > >>>> > > >>>> > http://localhost:8983/solr/providersearch/select?wt=json&state=state:%22CO%22&state1=state:%22NY%22&fl=ss,score&q=*:*&fq={!lucene%20v=$state} > > >>>> < > http://localhost:8983/solr/providersearch/select?wt=json&state=state:%22CO%22&state1=state:%22NY%22&fl=ss,score&q=*:*&fq=%7B!lucene%20v=$state%7D > > > > >>>> > > >>>> This returns 10,000 > > >>>> > > >>>> I want to put an IF statement around which v to use. > > >>>> > > >>>> > > >>>> > > >>>> > > >>>> > > >>>> > > >>>> On Fri, Jan 1, 2016 at 1:52 PM, William Bell > > >>>> wrote: > > >>>> > > >>>>> Sure. > > >>>>> > > >>>>> If the state:NY returns results filter by state:NY, if it does not, > > >>>>> then use state:CO. If we have results in NY, use it, otherwise use > CO. > > >>>>> > > >>>>> OK? > > >>>>> > > >>>>> On Fri, Jan 1, 2016 at 1:15 PM, Upayavira wrote: > > >>>>> > > >>>>>> > > >>>>>> > > >>>>>> On Thu, Dec 31, 2015, at 11:50 PM, William Bell wrote: > > >>>>>> > We are getting weird results with if(exists(a),b,c). We are > getting > > >>>>>> b+c!! > > >>>>>> > > > >>>>>> > > > >>>>>> > http://localhost:8983/solr/providersearch/select?q=*:*&wt=json&state=state:%22CO%22&state1=state:%22NY%22&fq=if(exists(query($state1)),{!lucene%20v=$state1},{!lucene%20v=$state}) > > >>>>>> < > http://localhost:8983/solr/providersearch/select?q=*:*&wt=json&state=state:%22CO%22&state1=state:%22NY%22&fq=if(exists(query($state1)),%7B!lucene%20v=$state1%7D,%7B!lucene%20v=$state%7D) > > > > >>>>>> > > > >>>>>> > I am getting NY and CO! > > >>>>>> > > > >>>>>> > I only want $state1, which is NY. > > >>>>>> > > > >>>>>> > Any other ways to craft this? > > >>>>>> > > >>>>>> Does this work at all? > > >>>>>> > > >>>>>> The if() function is a function query that can be used to sort, > boost > > >>>>>> and as calculated fields. I haven't seen them used in filtering. > > >>>>>> > > >>>>>> Also, the query() function does *not* do a query, it just says > "what > > >>>>>> would this document score for this query?" > > >>>>>> > > >>>>>> Can you describe in English what you are trying to do? > > >>>>>> > > >>>>>> Upayavira > > >>>>>> > > >>>>> > > >>>>> > > >>>>> > > >>>>> -- > > >>>>> Bill Bell > > >>>>> billnbell@gmail.com > > >>>>> cell 720-256-8076 > > >>>>> > > >>>> > > >>>> > > >>>> > > >>>> -- > > >>>> Bill Bell > > >>>> billnbell@gmail.com > > >>>> cell 720-256-8076 > > >>>> > > >>> > > >>> > > >>> > > >>> -- > > >>> Bill Bell > > >>> billnbell@gmail.com > > >>> cell 720-256-8076 > > >>> > > >> > > >> > > >> > > >> -- > > >> Bill Bell > > >> billnbell@gmail.com > > >> cell 720-256-8076 > > >> > > > > > > > > > > > > -- > > > Bill Bell > > > billnbell@gmail.com > > > cell 720-256-8076 > > > > > > > > > > > -- > > Bill Bell > > billnbell@gmail.com > > cell 720-256-8076 > -- Bill Bell billnbell@gmail.com cell 720-256-8076 --001a1142cc365bc41405285077c3--