aboutsummaryrefslogtreecommitdiff
path: root/src/client/util/SearchUtil.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/util/SearchUtil.ts')
-rw-r--r--src/client/util/SearchUtil.ts12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/client/util/SearchUtil.ts b/src/client/util/SearchUtil.ts
index 7b2c601fe..afa8ff575 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,7 +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 gotten = await rp.get(rpquery, { qs: { ...options, q: query } });
+ 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;
@@ -79,10 +85,12 @@ export namespace SearchUtil {
if (testDoc instanceof Doc && testDoc.type !== DocumentType.KVP && (options.allowAliases || testDoc.proto === undefined || theDocs.findIndex(d => Doc.AreProtosEqual(d, testDoc)) === -1)) {
theDocs.push(testDoc);
theLines.push([]);
+ } else {
+ result.numFound--;
}
}
- return { docs: theDocs, numFound: theDocs.length, highlighting, lines: theLines };
+ return { docs: theDocs, numFound: result.numFound, highlighting, lines: theLines };
}
export async function GetAliasesOfDocument(doc: Doc): Promise<Doc[]>;