From f9c85c73dde483aab1f904510c44c9e20824f0d7 Mon Sep 17 00:00:00 2001 From: Gilles Crettenand Date: Fri, 29 May 2015 11:01:24 +0200 Subject: [PATCH] Adapt to new Solr config : - category -> genre - cover in solr - producer -> producerCode --- lib/AudioBook.php | 4 ++-- lib/BookSearch.php | 7 +------ mobile.netbiblio.php | 27 ++++++++++++--------------- 3 files changed, 15 insertions(+), 23 deletions(-) diff --git a/lib/AudioBook.php b/lib/AudioBook.php index f77cd88..79b0e45 100644 --- a/lib/AudioBook.php +++ b/lib/AudioBook.php @@ -184,9 +184,9 @@ class AudioBook extends DbMapping } /** - * Retrieve the list of all categories + * Retrieve the list of all genres */ - public static function listOfCategories() + public static function ListOfGenres() { $sql = "SELECT LTRIM(RTRIM(Code)) as code, diff --git a/lib/BookSearch.php b/lib/BookSearch.php index fe57629..555fb20 100644 --- a/lib/BookSearch.php +++ b/lib/BookSearch.php @@ -25,12 +25,7 @@ class BookSearch $this->query = new SolrQuery(); $this->query->setQuery('*:*'); - $this->query->addField('id'); - $this->query->addField('title'); - $this->query->addField('author'); - $this->query->addField('code'); - $this->query->addField('category'); - $this->query->addField('summary'); + $this->query->addField('*'); $this->query->addParam('q.op', 'AND'); } diff --git a/mobile.netbiblio.php b/mobile.netbiblio.php index 0d6f5f3..ad35934 100644 --- a/mobile.netbiblio.php +++ b/mobile.netbiblio.php @@ -310,7 +310,7 @@ class NetBiblio extends WebService if (isset($queryArray['queryType'])) { $bs->addSortField('author', SolrQuery::ORDER_ASC); $bs->addSortField('title', SolrQuery::ORDER_ASC); - $bs->addSortField('producer'); + $bs->addSortField('producerCode'); $bs->addSortField('mediaType', SolrQuery::ORDER_ASC); } else { $bs->addSortField('availabilityDate'); @@ -323,15 +323,15 @@ class NetBiblio extends WebService $bs->addQuery($queryArray['queryText'], $type); } - if(isset($queryArray['category']) && is_array($queryArray['category'])) { - $selectedCategories = array_filter($queryArray['category'], function ($c) { + if(isset($queryArray['genre']) && is_array($queryArray['genre'])) { + $selectedGenres = array_filter($queryArray['genre'], function ($c) { return $c != '0'; }); - if (count($selectedCategories) > 0) { - $selectedCategories = array_map(function ($c) { - return 'categoryCode:'.SolrUtils::escapeQueryChars($c); - }, $selectedCategories); - $bs->addQuery('('.implode(' OR ', $selectedCategories).')', null, false); + if (count($selectedGenres) > 0) { + $selectedGenres = array_map(function ($c) { + return 'genreCode:'.SolrUtils::escapeQueryChars($c); + }, $selectedGenres); + $bs->addQuery('('.implode(' OR ', $selectedGenres).')', null, false); } } @@ -354,10 +354,7 @@ class NetBiblio extends WebService ); foreach ($results['response']['docs'] as $doc) { - $book = AudioBook::findBy('NoticeID', $doc['id'], true); - if($book) { - $data[] = $this->AddFiles($book); - } + $data[] = $this->AddFiles($doc); } return $data; @@ -368,9 +365,9 @@ class NetBiblio extends WebService return AudioBook::listOfReaders(); } - public function ListOfCategories() + public function ListOfGenres() { - return AudioBook::listOfCategories(); + return AudioBook::ListOfGenres(); } public function ListOfTypes() @@ -393,7 +390,7 @@ class NetBiblio extends WebService if($type == 'Jeunesse') { $s->addQuery(1, 'jeunesse'); } else { - $s->addQuery($type, 'category'); + $s->addQuery($type, 'genre'); } $s->addSortField('availabilityDate');