You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by William Bell <bi...@gmail.com> on 2016/01/01 00:50:52 UTC

Issue with if() statement

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})

I am getting NY and CO!

I only want $state1, which is NY.

Any other ways to craft this?


-- 
Bill Bell
billnbell@gmail.com
cell 720-256-8076

Re: Issue with if() statement

Posted by bi...@gmail.com.
Solr 5.3.1

Bill Bell
Sent from mobile


> On Dec 31, 2015, at 4:50 PM, William Bell <bi...@gmail.com> 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})
> 
> I am getting NY and CO!
> 
> I only want $state1, which is NY.
> 
> Any other ways to craft this?
> 
> 
> -- 
> Bill Bell
> billnbell@gmail.com
> cell 720-256-8076

Re: Issue with if() statement

Posted by Jack Krupansky <ja...@gmail.com>.
You can't have spaces in a function query - the %20 will get expanded to a
space (just as a "+" would.)

And fq is "filter query" anyway, not "function query". Try: fq={!func}...

Not sure what the solution to those embedded spaces is, but you probably
need function queries there as well.


-- Jack Krupansky

On Thu, Dec 31, 2015 at 6:50 PM, William Bell <bi...@gmail.com> 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})
>
> I am getting NY and CO!
>
> I only want $state1, which is NY.
>
> Any other ways to craft this?
>
>
> --
> Bill Bell
> billnbell@gmail.com
> cell 720-256-8076
>

Re: Issue with if() statement

Posted by William Bell <bi...@gmail.com>.
Also ne: not equal.

This is like KSH.

On Fri, Jan 1, 2016 at 2:40 PM, William Bell <bi...@gmail.com> wrote:

> Forgot last bit:
>
> fq={!switch case.gt.0=$state1
>                              default=$state
>                              func=len($state1)}</str>
>
>
> On Fri, Jan 1, 2016 at 2:39 PM, William Bell <bi...@gmail.com> wrote:
>
>> Maybe we can add function value on a switch?
>>
>> fq={!switch case.gt.0
>>                              default=$state
>>                              func=len($state1)}</str>
>>
>>
>>
>> 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 <bi...@gmail.com> 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}</str>
>>>
>>> So I tried the following to set all 50 states:
>>>
>>>
>>> fq={!switch case.all='*:*'
>>>                              case.CO='state:CO'
>>>                              case.NY='state:NY'
>>>                              v=$state1}</str>
>>>
>>>
>>> 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 <bi...@gmail.com>
>>> 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 <bi...@gmail.com>
>>>> 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 <bi...@gmail.com>
>>>>> 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 <uv...@odoko.co.uk> 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

Re: Issue with if() statement

Posted by William Bell <bi...@gmail.com>.
OK. I was able to get it to work by looking at {!switch} code. I had a heck
of a time trying to get parse() to work as a separate class.

q.add(new TermQuery(new Term("state", "CO"), Occur.MUST);
return q;

That never did anything.

Here is some code that worked...

http://localhost:8983/solr/providersearchfull/select?wt=json&state1=state:NY&fl=ss,score&df=state&q={!orquery}$state,$state1

Notice $state was not sent... It works.

Thoughts?

package hg.parsers;

import org.apache.commons.lang.StringUtils;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.BooleanClause.Occur;
import org.apache.lucene.search.BooleanQuery;
import org.apache.solr.common.params.CommonParams;
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.search.BooleanClause;
import org.apache.solr.parser.QueryParser;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.spans.SpanTermQuery;
import org.apache.solr.common.params.SolrParams;
import org.apache.solr.search.QueryParsing;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.search.QParser;
import org.apache.solr.search.QParserPlugin;
import org.apache.solr.search.SyntaxError;

/**
 * Created by bbell on 1/3/16.
 */
public class OrQueryParserPlugin extends QParserPlugin {
    //public static String NAME = "lucene";

    @Override
    public void init(NamedList args) {
    }

    @Override
    public QParser createParser(String qstr, SolrParams localParams,
SolrParams params, SolrQueryRequest req) {
        return new QParser(qstr, localParams, params, req) {
            QParser subParser;

            @Override
            public Query parse() throws SyntaxError {
                String v = localParams.get(QueryParsing.V);
                if (v == null || v.length() == 0) return null;
                String subQ = null;

                String[] arr = v.split(",");
                System.out.println("parse arr:" + arr.length + "," + v);
                if (arr != null && arr.length == 2) {
                    System.out.println("parse arr[0].length:" +
arr[0].length());
                    System.out.println("parse arr[1].length:" +
arr[1].length());
                    if (arr[0].trim().length() > 0) {
                        System.out.println("parse arr[0] params:" +
params.get(arr[0].trim()));
                        if (arr[0].trim().substring(0, 1).equals("$")) {
                            String val = params.get(arr[0].trim().substring(1));
                            if (val != null && val.length() > 0) {
                                subQ = val;
                                System.out.println("parse arr[0]:" +
arr[0].trim() + "," + subQ);
                            }
                        } else {
                            subQ = arr[0].trim();
                            System.out.println("parse arr[0]:" + subQ);
                        }
                    }
                    if (subQ == null && arr[1].trim().length() > 0) {
                        System.out.println("parse arr[1] params:" +
params.get(arr[1].trim()));
                        if (arr[1].trim().substring(0, 1).equals("$")) {
                            String val = params.get(arr[1].trim().substring(1));
                            if (val != null && val.length() > 0) {
                                subQ = val;
                                System.out.println("parse arr[1]:" +
arr[1].trim() + "," + subQ);
                            }
                        } else {
                            subQ = arr[1].trim();
                            System.out.println("parse arr[1]:" + subQ);
                        }
                    }
                } else {
                    subQ = null;
                }

                subParser = subQuery(subQ, null);
                return subParser.getQuery();
            }
            @Override
            public String[] getDefaultHighlightFields() {
                return subParser.getDefaultHighlightFields();
            }

            @Override
            public Query getHighlightQuery() throws SyntaxError {
                return subParser.getHighlightQuery();
            }

            @Override
            public void addDebugInfo(NamedList<Object> debugInfo) {
                subParser.addDebugInfo(debugInfo);
            }
        };
    }
}



.

On Sat, Jan 2, 2016 at 5:03 AM, Upayavira <uv...@odoko.co.uk> wrote:

> Hrmph. I've got an Ant based codebase for building custom components
> against Solr. I've been asked on numerous occasions to publish this
> codebase. It is now at:
>
> https://github.com/upayavira/custom-solr-components
>
> There's no sample code in there yet. I'll see if I can stick one in
> there now, but I'm not sure how much time I have today to pull it all
> together (making it look nice and clear takes much more effort than
> making it work!).
>
> Upayavira
>
> On Sat, Jan 2, 2016, at 02:15 AM, William Bell wrote:
> > Sample code for a simple query parser?
> >
> > On Fri, Jan 1, 2016 at 3:08 PM, Upayavira <uv...@odoko.co.uk> 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)}</str>
> > > >
> > > >
> > > > On Fri, Jan 1, 2016 at 2:39 PM, William Bell <bi...@gmail.com>
> > > wrote:
> > > >
> > > > > Maybe we can add function value on a switch?
> > > > >
> > > > > fq={!switch case.gt.0
> > > > >                              default=$state
> > > > >                              func=len($state1)}</str>
> > > > >
> > > > >
> > > > >
> > > > > 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 <bi...@gmail.com>
> > > 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}</str>
> > > > >>
> > > > >> So I tried the following to set all 50 states:
> > > > >>
> > > > >>
> > > > >> fq={!switch case.all='*:*'
> > > > >>                              case.CO='state:CO'
> > > > >>                              case.NY='state:NY'
> > > > >>                              v=$state1}</str>
> > > > >>
> > > > >>
> > > > >> 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 <billnbell@gmail.com
> >
> > > 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 <
> billnbell@gmail.com>
> > > > >>> 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 <
> billnbell@gmail.com>
> > > > >>>> 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 <uv...@odoko.co.uk>
> 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
>



-- 
Bill Bell
billnbell@gmail.com
cell 720-256-8076

Re: Issue with if() statement

Posted by Upayavira <uv...@odoko.co.uk>.
Hrmph. I've got an Ant based codebase for building custom components
against Solr. I've been asked on numerous occasions to publish this
codebase. It is now at:

https://github.com/upayavira/custom-solr-components

There's no sample code in there yet. I'll see if I can stick one in
there now, but I'm not sure how much time I have today to pull it all
together (making it look nice and clear takes much more effort than
making it work!).

Upayavira

On Sat, Jan 2, 2016, at 02:15 AM, William Bell wrote:
> Sample code for a simple query parser?
> 
> On Fri, Jan 1, 2016 at 3:08 PM, Upayavira <uv...@odoko.co.uk> 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)}</str>
> > >
> > >
> > > On Fri, Jan 1, 2016 at 2:39 PM, William Bell <bi...@gmail.com>
> > wrote:
> > >
> > > > Maybe we can add function value on a switch?
> > > >
> > > > fq={!switch case.gt.0
> > > >                              default=$state
> > > >                              func=len($state1)}</str>
> > > >
> > > >
> > > >
> > > > 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 <bi...@gmail.com>
> > 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}</str>
> > > >>
> > > >> So I tried the following to set all 50 states:
> > > >>
> > > >>
> > > >> fq={!switch case.all='*:*'
> > > >>                              case.CO='state:CO'
> > > >>                              case.NY='state:NY'
> > > >>                              v=$state1}</str>
> > > >>
> > > >>
> > > >> 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 <bi...@gmail.com>
> > 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 <bi...@gmail.com>
> > > >>> 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 <bi...@gmail.com>
> > > >>>> 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 <uv...@odoko.co.uk> 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

Re: Issue with if() statement

Posted by William Bell <bi...@gmail.com>.
Sample code for a simple query parser?

On Fri, Jan 1, 2016 at 3:08 PM, Upayavira <uv...@odoko.co.uk> 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)}</str>
> >
> >
> > On Fri, Jan 1, 2016 at 2:39 PM, William Bell <bi...@gmail.com>
> wrote:
> >
> > > Maybe we can add function value on a switch?
> > >
> > > fq={!switch case.gt.0
> > >                              default=$state
> > >                              func=len($state1)}</str>
> > >
> > >
> > >
> > > 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 <bi...@gmail.com>
> 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}</str>
> > >>
> > >> So I tried the following to set all 50 states:
> > >>
> > >>
> > >> fq={!switch case.all='*:*'
> > >>                              case.CO='state:CO'
> > >>                              case.NY='state:NY'
> > >>                              v=$state1}</str>
> > >>
> > >>
> > >> 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 <bi...@gmail.com>
> 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 <bi...@gmail.com>
> > >>> 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 <bi...@gmail.com>
> > >>>> 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 <uv...@odoko.co.uk> 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

Re: Issue with if() statement

Posted by Upayavira <uv...@odoko.co.uk>.
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)}</str>
> 
> 
> On Fri, Jan 1, 2016 at 2:39 PM, William Bell <bi...@gmail.com> wrote:
> 
> > Maybe we can add function value on a switch?
> >
> > fq={!switch case.gt.0
> >                              default=$state
> >                              func=len($state1)}</str>
> >
> >
> >
> > 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 <bi...@gmail.com> 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}</str>
> >>
> >> So I tried the following to set all 50 states:
> >>
> >>
> >> fq={!switch case.all='*:*'
> >>                              case.CO='state:CO'
> >>                              case.NY='state:NY'
> >>                              v=$state1}</str>
> >>
> >>
> >> 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 <bi...@gmail.com> 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 <bi...@gmail.com>
> >>> 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 <bi...@gmail.com>
> >>>> 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 <uv...@odoko.co.uk> 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

Re: Issue with if() statement

Posted by William Bell <bi...@gmail.com>.
Forgot last bit:

fq={!switch case.gt.0=$state1
                             default=$state
                             func=len($state1)}</str>


On Fri, Jan 1, 2016 at 2:39 PM, William Bell <bi...@gmail.com> wrote:

> Maybe we can add function value on a switch?
>
> fq={!switch case.gt.0
>                              default=$state
>                              func=len($state1)}</str>
>
>
>
> 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 <bi...@gmail.com> 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}</str>
>>
>> So I tried the following to set all 50 states:
>>
>>
>> fq={!switch case.all='*:*'
>>                              case.CO='state:CO'
>>                              case.NY='state:NY'
>>                              v=$state1}</str>
>>
>>
>> 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 <bi...@gmail.com> 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 <bi...@gmail.com>
>>> 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 <bi...@gmail.com>
>>>> 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 <uv...@odoko.co.uk> 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

Re: Issue with if() statement

Posted by William Bell <bi...@gmail.com>.
Maybe we can add function value on a switch?

fq={!switch case.gt.0
                             default=$state
                             func=len($state1)}</str>



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 <bi...@gmail.com> 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}</str>
>
> So I tried the following to set all 50 states:
>
>
> fq={!switch case.all='*:*'
>                              case.CO='state:CO'
>                              case.NY='state:NY'
>                              v=$state1}</str>
>
>
> 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 <bi...@gmail.com> 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 <bi...@gmail.com> 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 <bi...@gmail.com>
>>> 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 <uv...@odoko.co.uk> 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

Re: Issue with if() statement

Posted by William Bell <bi...@gmail.com>.
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}</str>

So I tried the following to set all 50 states:


fq={!switch case.all='*:*'
                             case.CO='state:CO'
                             case.NY='state:NY'
                             v=$state1}</str>


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 <bi...@gmail.com> 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 <bi...@gmail.com> 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 <bi...@gmail.com> 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 <uv...@odoko.co.uk> 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

Re: Issue with if() statement

Posted by William Bell <bi...@gmail.com>.
Thanks that indeed works tt=${state1}. But that was just a passing question.

I see an empty "*case*", "default" and a "case.VAL". I think I have
anything I need. After rereading. We might want to add to "case.VAL"
something like "case.'state:CO'" with a single quote. Right now it does not
appear to handle spaces or :.... I digress.

I got it to work with {!switch}.

http://localhost:8983/solr/providersearchfull/select?wt=xml&state1=state:%22NY%22&fl=score&q=*:*&fq={!switch%20case=$state2%20default=$state1%20v=$state1}

If the user passes state1, it will not be empty and the default will pick
up all 50 states.

If the user does not pass state1, but passes state2, the case empty will
pick up since $state1 is empty, and it works.

http://localhost:8983/solr/providersearchfull/select?wt=xml&state2=state:%22CO%22&fl=score&q=*:*&fq={!switch%20case=$state2%20default=$state1%20v=$state1}

The only that that changes is if I set as a param state1 or state2.

If I send both state1 and state2, state1 takes precedence.

http://localhost:8983/solr/providersearchfull/select?wt=xml&state1=state:%22NY%22&state2=state:%22CO%22&fl=score&q=*:*&fq={!switch%20case=$state2%20default=$state1%20v=$state1}

Kinda interesting.

The query I sent earlier : {!orquery}query1,query2 will return query1 is it
is not empty, otherwise if query1 is empty it will run query2. That was the
code I sent last night.

I am going to send some more code, since I could not get TermQuery to work
like I have it in PayLoad. And need some help debugging that.

Thanks!



On Sun, Jan 3, 2016 at 11:32 AM, Erik Hatcher <er...@gmail.com>
wrote:

> I haven’t fully digested this thread, but wanted to comment on this one.
> &param=$something doesn’t substitute.  Only “local” params (inside local
> param syntax curly brackets) do that.  If you want to substitute a raw
> parameter use curly brackets.  You could, in this example, use
> &tt=${state1}, I believe, and it would substitute.  Confusingly, local
> param curly brackets are _not_ the same as param substitution curly
> brackets.
>
> I am skeptical that anything custom is needed for what you’re trying to
> do, but again I haven’t fully digested what’s going on here yet.  There is
> some param substitution and {!switch} voodoo in example/files that ships
> with Solr, and that might be helpful.  Check out how that works.  I’m in
> the polishing stages of a a collaborative blog post on example/files that
> will detail these tricks a bit - will publish that in the next few days.
>
> —
> Erik Hatcher, Senior Solutions Architect
> http://www.lucidworks.com <http://www.lucidworks.com/>
>
>
>
> > On Jan 1, 2016, at 4:15 PM, William Bell <bi...@gmail.com> 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}
> >
> > 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 <bi...@gmail.com>
> 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 <bi...@gmail.com>
> 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 <uv...@odoko.co.uk> 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

Re: Issue with if() statement

Posted by Erik Hatcher <er...@gmail.com>.
I haven’t fully digested this thread, but wanted to comment on this one.  &param=$something doesn’t substitute.  Only “local” params (inside local param syntax curly brackets) do that.  If you want to substitute a raw parameter use curly brackets.  You could, in this example, use &tt=${state1}, I believe, and it would substitute.  Confusingly, local param curly brackets are _not_ the same as param substitution curly brackets.

I am skeptical that anything custom is needed for what you’re trying to do, but again I haven’t fully digested what’s going on here yet.  There is some param substitution and {!switch} voodoo in example/files that ships with Solr, and that might be helpful.  Check out how that works.  I’m in the polishing stages of a a collaborative blog post on example/files that will detail these tricks a bit - will publish that in the next few days.

—
Erik Hatcher, Senior Solutions Architect
http://www.lucidworks.com <http://www.lucidworks.com/>



> On Jan 1, 2016, at 4:15 PM, William Bell <bi...@gmail.com> 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}
> 
> 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 <bi...@gmail.com> 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 <bi...@gmail.com> 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 <uv...@odoko.co.uk> 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


Re: Issue with if() statement

Posted by William Bell <bi...@gmail.com>.
Another weirdness:

http://localhost:8983/solr/providersearch/select?wt=json&state=state:CO&state1=state:NY&fl=*&q=*:*&tt=$state1&fq={!lucene%20v=$tt}

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 <bi...@gmail.com> 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 <bi...@gmail.com> 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 <uv...@odoko.co.uk> 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

Re: Issue with if() statement

Posted by Upayavira <uv...@odoko.co.uk>.
I'm afraid I cannot see how this can be done - at least without coding.

Basically, when your filter is being evaluated, you want to make use of
knowledge of the main query - for normal queries, that isn't possible,
as they are created independently.

You could use potentially use a "post filter" in which the final set of
documents are passed through a filter - but even then, you wouldn't know
how *why* a document matched, only that it did. So really, you're gonna
need to do this as two queries - one to find out the number of docs
matching your state, and then send a second query based upon that.

With some coding, you could probably get that to be a single request to
Solr, but it is going to remain two queries against the index.

Upayavira



On Fri, Jan 1, 2016, at 09: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}
> 
> 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}
> 
> 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 <bi...@gmail.com> 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 <uv...@odoko.co.uk> 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

Re: Issue with if() statement

Posted by William Bell <bi...@gmail.com>.
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}

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}

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 <bi...@gmail.com> 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 <uv...@odoko.co.uk> 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

Re: Issue with if() statement

Posted by William Bell <bi...@gmail.com>.
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 <uv...@odoko.co.uk> 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})
> >
> > 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

Re: Issue with if() statement

Posted by Upayavira <uv...@odoko.co.uk>.

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})
> 
> 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