Solr Facet for event dates

I have an event table that has a start date and an end date, e.g.

============================================== id | name | start_date | end_date ============================================== 1 | Test Event 1 | 2011-11-20 | 2011-12-20 ---------------------------------------------- 2 | My Event 2 | 2011-12-05 | 2011-12-26 ---------------------------------------------- 3 | My Event 3 | 2012-12-26 | 2012-01-11 ---------------------------------------------- 

Now I want to have a solr face that looks like this, and I cannot get the parameters on the right.

 ================== Dates ------------------ Today [2] This Week [2] This Month [2] Next Month [1] 

Note that the facet must consider the start date and end date. Kind of gouping?

What should the cut options be for this?

Thanks in advance for any help.

+4
source share
2 answers

I finally got it using the Facet Multi Query solarium libraries, based on the example http://wiki.solarium-project.org/index.php/V2:Facet_multiquery

Part of my Zend app looks like

 $dateFacetSet = $query->getFacetSet(); $dateFacet = $dateFacetSet->createFacetMultiQuery('dates'); $dateFacet->createQuery('Today', 'type:event AND sdate:[* TO NOW/DAY] AND edate:[NOW/DAY TO * ]'); $dateFacet->createQuery('This-Week', 'type:event AND sdate:[* TO ' . $this->view->date_w["end"] . 'T23:59:59Z] AND edate:[' . $this->view->date_w["start"] . 'T00:00:00Z TO * ]'); $dateFacet->createQuery('This-Month', 'type:event AND sdate:[* TO ' . $this->view->date_m["end"] . 'T23:59:59Z] AND edate:[' . $this->view->date_m["start"] . 'T00:00:00Z TO * ]'); 

If anyone wants to know more, please let me know.

These parameters will catch what I need so far, but have not tested extensively.

+3
source

You can put $ Startdate.'T01: 00: 59Z "$ Enddate.'T23: 59: 59Z

0
source

Source: https://habr.com/ru/post/1384679/


All Articles