aboutsummaryrefslogtreecommitdiff
path: root/src/client/util/SearchUtil.ts
diff options
context:
space:
mode:
authoranika-ahluwalia <anika.ahluwalia@gmail.com>2020-08-17 17:45:08 -0500
committeranika-ahluwalia <anika.ahluwalia@gmail.com>2020-08-17 17:45:08 -0500
commit4eb34dd81ebf0b5f64c4552265dd55ec0290e332 (patch)
tree719778179122aba9bfb9d66abf15171a6dfdb93f /src/client/util/SearchUtil.ts
parent5adf15574ac6423e09617b3d756d98ea8cdc75c5 (diff)
parent39e49bbb6943a546123765f8969ea4f054157ae5 (diff)
Merge branch 'master' of https://github.com/browngraphicslab/Dash-Web into menu_restructure
Diffstat (limited to 'src/client/util/SearchUtil.ts')
-rw-r--r--src/client/util/SearchUtil.ts9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/client/util/SearchUtil.ts b/src/client/util/SearchUtil.ts
index b63fc8991..ce96ab67b 100644
--- a/src/client/util/SearchUtil.ts
+++ b/src/client/util/SearchUtil.ts
@@ -28,7 +28,9 @@ export namespace SearchUtil {
start?: number;
rows?: number;
fq?: string;
+ sort?: string;
allowAliases?: boolean;
+ onlyAliases?: boolean;
"facet"?: string;
"facet.field"?: string;
}
@@ -37,8 +39,11 @@ export namespace SearchUtil {
export async function Search(query: string, returnDocs: boolean, options: SearchParams = {}) {
query = query || "*"; //If we just have a filter query, search for * as the query
const rpquery = Utils.prepend("/dashsearch");
- const replacedQuery = query.replace(/type_t:([^ )])/g, (substring, arg) => `{!join from=id to=proto_i}type_t:${arg}`);
- const gotten = await rp.get(rpquery, { qs: { ...options, sort: "lastModified_d desc", q: replacedQuery } });
+ let replacedQuery = query.replace(/type_t:([^ )])/g, (substring, arg) => `{!join from=id to=proto_i}type_t:${arg}`);
+ if (options.onlyAliases) {
+ replacedQuery = `{!join from=id to=proto_i}DEFAULT:${replacedQuery}`;
+ }
+ const gotten = await rp.get(rpquery, { qs: { ...options, q: replacedQuery } });
const result: IdSearchResult = gotten.startsWith("<") ? { ids: [], docs: [], numFound: 0, lines: [] } : JSON.parse(gotten);
if (!returnDocs) {
return result;