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 <billnb...@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 <u...@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
> > billnb...@gmail.com
> > cell 720-256-8076
> >
> 
> 
> 
> -- 
> Bill Bell
> billnb...@gmail.com
> cell 720-256-8076

Reply via email to