Skip to content

Commit

Permalink
fix(search): add support for untyped, grouped search strings
Browse files Browse the repository at this point in the history
AFFECTS PACKAGES:
@esri/arcgis-rest-portal

ISSUES CLOSED: #544
  • Loading branch information
jgravois committed Apr 24, 2019
1 parent ff90f51 commit 39fc213
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/arcgis-rest-portal/src/util/SearchQueryBuilder.ts
Expand Up @@ -137,9 +137,10 @@ export class SearchQueryBuilder implements IParamBuilder {
);
return this;
}
this.commit();
this.openGroups--;
this.q += ")";
return this.commit();
return this;
}

/**
Expand Down
15 changes: 14 additions & 1 deletion packages/arcgis-rest-portal/test/util/SearchQueryBuilder.test.ts
Expand Up @@ -16,7 +16,7 @@ describe("SearchQueryBuilder", () => {
console.warn = originalWarn;
});

it("should return and empty string when called with no other functions", () => {
it("should return an empty string when called with no other functions", () => {
const query = new SearchQueryBuilder().toParam();
expect(query).toEqual("");
});
Expand Down Expand Up @@ -86,6 +86,19 @@ describe("SearchQueryBuilder", () => {
expect(query).toEqual("(title:[a TO z])");
});

it("should format a more complex group", () => {
const query = new SearchQueryBuilder()
.startGroup()
.match("California")
.or()
.match("recent")
.endGroup()
.and()
.match("fires")
.toParam();
expect(query).toEqual("(California OR recent) AND fires");
});

it("should boost the previous search", () => {
const query = new SearchQueryBuilder()
.match("test")
Expand Down

0 comments on commit 39fc213

Please sign in to comment.