Commit 38f90299 authored by Robert Knight's avatar Robert Knight

BinaryOpFilter => BooleanOpFilter

The name `BinaryOpFilter` was wrong because the filter can take any
number of sub-filters. Also the 'AND' and 'OR' combinators, in the
context of search engines, are normally described as boolean operators.
parent d4d8c0bf
......@@ -78,9 +78,9 @@ class TermFilter {
*
* @implements {Filter}
*/
class BinaryOpFilter {
class BooleanOpFilter {
/**
* @param {'and'|'or'} op - Binary operator
* @param {'and'|'or'} op - Boolean operator
* @param {Filter[]} filters - Array of filters to test against
*/
constructor(op, filters) {
......@@ -175,7 +175,7 @@ export function filterAnnotations(annotations, filters) {
const anyFields = ['quote', 'text', 'tag', 'user'];
termFilters = filter.terms.map(
term =>
new BinaryOpFilter(
new BooleanOpFilter(
'or',
anyFields.map(field => makeTermFilter(field, term))
)
......@@ -183,10 +183,10 @@ export function filterAnnotations(annotations, filters) {
} else {
termFilters = filter.terms.map(term => makeTermFilter(field, term));
}
return new BinaryOpFilter(filter.operator, termFilters);
return new BooleanOpFilter(filter.operator, termFilters);
});
const rootFilter = new BinaryOpFilter('and', fieldFilters);
const rootFilter = new BooleanOpFilter('and', fieldFilters);
return annotations
.filter(ann => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment