2017-03-09 37 views
1
$client = $this->solr->getClient(); 
     $query = $client->createSelect(); 
     $facetSet = $query->getFacetSet(); 
     $facetSet->createFacetField('id')->setField('publication_year'); 

     $facet = $facetSet->createFacetRange('yearsranges'); 
     $facet->setField('publication_year'); 

     $facet->setStart(--MIN DATE VALUE--); 
     $facet->setGap(--I NEED TO MAKE RANGE OF 10 YEARS--); 
     $facet->setEnd(--NOW DATE TIME--); 

     $solrQuery = '*:*'; 

     $query->setQuery($solrQuery); 
     $query->setRows(0); 

     $data = $client->select($query)->getFacetSet()->getFacet('yearsranges'); 

     dump($data); 
     die; 

我们先问你,如果它是有效的,使日期范围在Solr的面Solr的集合中 “PUBLICATION_YEAR”字段。这个日期实际上是这种格式的字符串。Symfony的日光浴束日期时间范围

"2009-10-29T23:00:00Z" 

回答

4

是它是有效的,或只是使用查询过滤器:

$createQuery->createFilterQuery('range')->setQuery('createdate:[1995-12-31T23:59:59.999Z TO 2007-03-06T00:00:00Z]'); 

对于面:

$facet->createQuery('createdate:[1995-12-31T23:59:59.999Z TO 2007-03-06T00:00:00Z]');