Symfony Solarium 捆绑日期时间范围
Symfony Solarium bundle datetime range
$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中设置日期范围是否有效
"publication_year" solr 集合中的字段。这个日期其实就是这种格式的字符串。
"2009-10-29T23:00:00Z"
是的,它有效或仅使用查询过滤器:
$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]');
$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中设置日期范围是否有效 "publication_year" solr 集合中的字段。这个日期其实就是这种格式的字符串。
"2009-10-29T23:00:00Z"
是的,它有效或仅使用查询过滤器:
$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]');