Re: Filter Query with conditional fields

2018-04-16 Thread Erick Erickson
Be a little careful with NOW in filter queries if you intend to have
the cache be effective, see:
https://lucidworks.com/2012/02/23/date-math-now-and-filter-queries/

Best,
Erick

On Mon, Apr 16, 2018 at 2:15 AM, Emir Arnautović
 wrote:
> 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  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
>


Re: Filter Query with conditional fields

2018-04-16 Thread Emir Arnautović
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  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



Filter Query with conditional fields

2018-04-16 Thread jcondotta
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