[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 ...) ...