add duration to search parameters
This commit is contained in:
@@ -59,6 +59,11 @@ class BookSearch
|
|||||||
$this->queryParts[] = $queryText;
|
$this->queryParts[] = $queryText;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function addRange($field, $min = '*', $max = '*')
|
||||||
|
{
|
||||||
|
$this->queryParts[] = sprintf('%s:[%s TO %s]', $field, $min, $max);
|
||||||
|
}
|
||||||
|
|
||||||
public function addSortField($field, $order = \SolrQuery::ORDER_DESC)
|
public function addSortField($field, $order = \SolrQuery::ORDER_DESC)
|
||||||
{
|
{
|
||||||
$this->query->addSortField($field, $order);
|
$this->query->addSortField($field, $order);
|
||||||
|
|||||||
@@ -580,18 +580,29 @@ class NetBiblio extends WebService
|
|||||||
* ° queryText : the text to search for
|
* ° queryText : the text to search for
|
||||||
* ° queryType : the field to search in, defaults to 'text'
|
* ° queryType : the field to search in, defaults to 'text'
|
||||||
*
|
*
|
||||||
* ° genre : array of 'genreCode' to search for
|
|
||||||
* ° jeunesse : only display books for kids (must have format 'jeunesse' => array('filtrer' => 'filtrer')
|
* ° jeunesse : only display books for kids (must have format 'jeunesse' => array('filtrer' => 'filtrer')
|
||||||
|
*
|
||||||
* ° producerCode : filter by 'producerCode'
|
* ° producerCode : filter by 'producerCode'
|
||||||
|
* ° genreCode : filter by 'genreCode'
|
||||||
|
* ° author : filter by 'author'
|
||||||
* ° reader : filter by 'reader'
|
* ° reader : filter by 'reader'
|
||||||
|
* ° motsMatieres : filter by 'motsMatieres'
|
||||||
|
*
|
||||||
|
* ° duration : exact duration in hours, duration are saved as float in Solr
|
||||||
|
* ° durationMin : minimal duration in hours
|
||||||
|
* ° durationMax : maximal duration in hours
|
||||||
*
|
*
|
||||||
* ° count : number of results we want
|
* ° count : number of results we want
|
||||||
* ° page : page to start at (0 is the first)
|
* ° page : page to start at (0 is the first)
|
||||||
*
|
*
|
||||||
|
* Shortcuts :
|
||||||
|
*
|
||||||
|
* ° producer : synonym for 'producerCode' (see above)
|
||||||
|
* ° genre : synonym for 'genreCode' (see above)
|
||||||
|
*
|
||||||
* Deprecated, but still in use on mobile apps :
|
* Deprecated, but still in use on mobile apps :
|
||||||
*
|
*
|
||||||
* ° category : synonym for 'genre' (see above)
|
* ° category : synonym for 'genre' (see above)
|
||||||
* ° producer : synonym for 'producerCode' (see above)
|
|
||||||
*
|
*
|
||||||
* Return value :
|
* Return value :
|
||||||
*
|
*
|
||||||
@@ -658,6 +669,14 @@ class NetBiblio extends WebService
|
|||||||
$bs->addQuery(1, 'jeunesse');
|
$bs->addQuery(1, 'jeunesse');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(isset($queryArray['duration'])) {
|
||||||
|
$bs->addQuery($queryArray['duration'], 'duration');
|
||||||
|
} else if(isset($queryArray['durationMin']) || isset($queryArray['durationMax'])) {
|
||||||
|
$min = isset($queryArray['durationMin']) ? $queryArray['durationMin'] : '*';
|
||||||
|
$max = isset($queryArray['durationMax']) ? $queryArray['durationMax'] : '*';
|
||||||
|
$bs->addRange('duration', $min, $max);
|
||||||
|
}
|
||||||
|
|
||||||
$availableFields = array('producerCode', 'genreCode', 'author', 'reader', 'motsMatieres');
|
$availableFields = array('producerCode', 'genreCode', 'author', 'reader', 'motsMatieres');
|
||||||
foreach($availableFields as $q) {
|
foreach($availableFields as $q) {
|
||||||
if(isset($queryArray[$q]) && (
|
if(isset($queryArray[$q]) && (
|
||||||
|
|||||||
Reference in New Issue
Block a user