Symfony Solarium捆绑日期时间范围

时间:2017-03-09 11:14:26

标签: symfony solr solarium

$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 facets中制作日期范围是否有效 solr集合中的“publication_year”字段。此日期实际上是此格式的字符串。

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

1 个答案:

答案 0 :(得分: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]');