Skip to content

Commit

Permalink
add advanced search filter
Browse files Browse the repository at this point in the history
  • Loading branch information
baloola committed Feb 22, 2024
1 parent 10c6ba0 commit 5873dbf
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/locales/en/texts.json
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,8 @@
"and": "Match all filters (and)",
"or": "Match any filters (or)"
},
"matches": "matches",
"matches": "matches (case-sensitive)",
"matches_ci": "matches (case-insensitive)",
"metaDescription": "Search through the data offering of {title}.",
"modifyCriteria": "Please modify the search criteria.",
"noItemsFound": "No items found for the given filters.",
Expand Down
21 changes: 21 additions & 0 deletions src/models/cql2/operators/advanced.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,24 @@ export class CqlLike extends CqlComparisonOperator {
}

}
export class CqlILike extends CqlComparisonOperator {

static SYMBOL = "ilike";

constructor(pred = null, obj = null) {
super(CqlILike.SYMBOL, pred, obj);
}

static get label() {
return "~ (Aa)";
}

static get longLabel() {
return i18n.t('search.matches_ci');
}

static get description() {
return i18n.t('search.likeOperatorDescription');
}

}
5 changes: 3 additions & 2 deletions src/models/cql2/queryable.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { formatKey } from "@radiantearth/stac-fields/helper";
import i18n from '../../i18n.js';
import { CqlEqual, CqlGreaterThan, CqlGreaterThanEqual, CqlLessThan, CqlLessThanEqual, CqlNotEqual } from "./operators/comparison";
import { CqlLike } from "./operators/advanced";
import { CqlLike, CqlILike } from "./operators/advanced";

export default class Queryable {

Expand Down Expand Up @@ -103,8 +103,9 @@ export default class Queryable {
ops.push(CqlGreaterThan);
ops.push(CqlGreaterThanEqual);
}
else if (this.isText && cql.advancedComparison) {
else if (this.isText ) {
ops.push(CqlLike);
ops.push(CqlILike);
}
return ops;
}
Expand Down

0 comments on commit 5873dbf

Please sign in to comment.