diff options
| author | geireann <60007097+geireann@users.noreply.github.com> | 2020-08-17 23:25:49 +0800 |
|---|---|---|
| committer | geireann <60007097+geireann@users.noreply.github.com> | 2020-08-17 23:25:49 +0800 |
| commit | d3a28452843dbbb94b79d3d9617076c7327fbfb9 (patch) | |
| tree | 54a8e004306158eb2583c39fd0d0706fc0645428 /src/client/util | |
| parent | 1baff66d1fe34a36db4aa5c817f049f4c1b04a1c (diff) | |
| parent | 5b43fb7d4c5978d311f65639836c31efb1501e6c (diff) | |
Merge branch 'master' into presentation_updates
Diffstat (limited to 'src/client/util')
| -rw-r--r-- | src/client/util/HypothesisUtils.ts | 2 | ||||
| -rw-r--r-- | src/client/util/SearchUtil.ts | 6 |
2 files changed, 6 insertions, 2 deletions
diff --git a/src/client/util/HypothesisUtils.ts b/src/client/util/HypothesisUtils.ts index 9ede94e4b..04e937878 100644 --- a/src/client/util/HypothesisUtils.ts +++ b/src/client/util/HypothesisUtils.ts @@ -34,7 +34,7 @@ export namespace Hypothesis { const results: Doc[] = []; await SearchUtil.Search("web", true).then(action(async (res: SearchUtil.DocSearchResult) => { - const docs = await Promise.all(res.docs.map(async doc => (await Cast(doc.extendsDoc, Doc)) || doc)); + const docs = res.docs; const filteredDocs = docs.filter(doc => doc.author === Doc.CurrentUserEmail && doc.type === DocumentType.WEB && doc.data ); diff --git a/src/client/util/SearchUtil.ts b/src/client/util/SearchUtil.ts index b63fc8991..6dafbd58e 100644 --- a/src/client/util/SearchUtil.ts +++ b/src/client/util/SearchUtil.ts @@ -29,6 +29,7 @@ export namespace SearchUtil { rows?: number; fq?: string; allowAliases?: boolean; + onlyAliases?: boolean; "facet"?: string; "facet.field"?: string; } @@ -37,7 +38,10 @@ 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}`); + 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, sort: "lastModified_d desc", q: replacedQuery } }); const result: IdSearchResult = gotten.startsWith("<") ? { ids: [], docs: [], numFound: 0, lines: [] } : JSON.parse(gotten); if (!returnDocs) { |
