lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Emir Arnautović <emir.arnauto...@sematext.com>
Subject Re: Filter Query with conditional fields
Date Mon, 16 Apr 2018 09:15:28 GMT
Hi,
You can probably do something like fq=latestEventDate:[$startDate TO $endDate] OR (!latestEventDate:[*
TO *] AND dateCreated:[$startDate TO $endDate])&startDate=.,,&endDate=…

But it is probably better to merge those two dates at index time to some searchDate field
and use that one for searching. You can do it either in your indexing code or use UpdateRequestProcessor(s)
to achieve that.

HTH,
Emir
--
Monitoring - Log Management - Alerting - Anomaly Detection
Solr & Elasticsearch Consulting Support Training - http://sematext.com/



> On 16 Apr 2018, at 11:02, jcondotta <jefferson.condotta@gmail.com> wrote:
> 
> Hi Folks, I've started on Solr World short time ago, I've been working on
> some filter query changes, the most of question that I've had i could
> understand, reading this forum, thanks a lot.
> 
> I've a situation, on my schema there are 2 fields that I've to check:
> latestEventDate and dateCreated.
> 
> By default when the user opens my search page, it should bring all documents
> with range between 1 ago and now.
> latestEventDate:([NOW-1YEAR TO NOW])
> 
> but I should also retrieve documents that don't have any value on
> latestEventDate, I mean with null value.
> 
> next I've to check when the user clicks on search, it should retrieve all
> documents with the date range selected, but for documents which don't have
> value on latestEventDate my query should filter on dateCreated.
> Ex:
> if(latestEventDate != null){
> // Search on latestEventDate
> }else{
>  // Search on dateCreated
> }
> 
> 
> Hopefully I could be clear on my explanation, any help is gonna be welcome.
> I hope as soon as possible be able to help other guys here.
> 
> Thanks a lot.
> 
> 
> 
> --
> Sent from: http://lucene.472066.n3.nabble.com/Solr-User-f472068.html


Mime
View raw message