[UI/Mobile] Search keywords are now ANDed

This commit is contained in:
emeric
2015-12-10 19:52:51 +01:00
parent 6db3606a4b
commit 3b9745bd54
5 changed files with 33 additions and 11 deletions
+2
View File
@@ -17,6 +17,8 @@
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
*/
#include "logger/Logger.hpp"
#include "SearchFilter.hpp"
namespace Database
+13 -2
View File
@@ -64,12 +64,23 @@ class SearchFilter
return SearchFilter({{field, {id} }});
}
// Single Field Name match
static SearchFilter ByName(Field field, std::vector<std::string> keywords)
// Single Field Name match OR
static SearchFilter ByNameOr(Field field, std::vector<std::string> keywords)
{
return NameLikeMatch({{{field, keywords}}});
}
// Single Field Name match AND
static SearchFilter ByNameAnd(Field field, std::vector<std::string> keywords)
{
NameLikeMatchType nameLikeMatch;
for (auto keyword : keywords)
nameLikeMatch.push_back({{{field, {keyword}}}});
return NameLikeMatch(nameLikeMatch);
}
// The filter is a AND of the following conditions:
// ((Field1.name LIKE STR1-1 OR Field1.name LIKE STR1-2 ...) OR (Field2.name LIKE STR2-1 OR Field2.name LIKE STR2-2 ...) ...
+3 -3
View File
@@ -95,9 +95,9 @@ Audio::Audio(Wt::WContainerWidget *parent)
// Song
auto keywords = splitString(edit->text().toUTF8(), " ");;
releaseSearch->search(SearchFilter::ByName(SearchFilter::Field::Release, keywords), SEARCH_NB_ITEMS);
artistSearch->search(SearchFilter::ByName(SearchFilter::Field::Artist, keywords), SEARCH_NB_ITEMS);
trackSearch->search(SearchFilter::ByName(SearchFilter::Field::Track, keywords), SEARCH_NB_ITEMS);
releaseSearch->search(SearchFilter::ByNameAnd(SearchFilter::Field::Release, keywords), SEARCH_NB_ITEMS);
artistSearch->search(SearchFilter::ByNameAnd(SearchFilter::Field::Artist, keywords), SEARCH_NB_ITEMS);
trackSearch->search(SearchFilter::ByNameAnd(SearchFilter::Field::Track, keywords), SEARCH_NB_ITEMS);
artistSearch->show();
releaseSearch->show();
-2
View File
@@ -20,8 +20,6 @@
#ifndef UI_MOBILE_TRACK_SEARCH_HPP
#define UI_MOBILE_TRACK_SEARCH_HPP
#include <boost/algorithm/string/split.hpp>
#include <Wt/WContainerWidget>
#include <Wt/WSignal>