1

How can I add a clause in php Solarium to filter by date? like omit all the results where date > today.

$query = $client->createSelect();
$query->createFilterQuery('myDateField')->setQuery(
    sprintf('myDateField:%s', /*WHAT TO PUT HERE?*/)
);

thanks

user3174311
  • 1,714
  • 5
  • 28
  • 66
  • 1
    try &fq=date:[2020-11-10T00:00:00Z TO NOW]&sort=date desc – Abhijit Bashetti Nov 23 '20 at 13:58
  • this is the syntax for SOLR, I'd need to use it in Solarium and filter a resultset. I updated my question for clarity. – user3174311 Nov 23 '20 at 14:05
  • 1
    The query should work the same. `[2020-11-10T00:00:00Z TO NOW]` in the query part. It's one of the examples in the Solarium manual (just for a regular integer value): `$query->createFilterQuery('maxprice')->setQuery('price:[1 TO 300]');` – MatsLindh Nov 23 '20 at 14:07

1 Answers1

0

Your code would be in solarium for solr would be :

$query->createFilterQuery('myDateField')->setQuery(
    sprintf('myDateField:[2020-11-10T00:00:00Z TO NOW]')
);
Abhijit Bashetti
  • 8,518
  • 7
  • 35
  • 47