diff options
-rw-r--r-- | src/server/Search.ts | 48 |
1 files changed, 28 insertions, 20 deletions
diff --git a/src/server/Search.ts b/src/server/Search.ts index 59bdd4803..1d8cfdcf0 100644 --- a/src/server/Search.ts +++ b/src/server/Search.ts @@ -7,31 +7,39 @@ export class Search { private url = 'http://localhost:8983/solr/'; public async updateDocument(document: any) { - return rp.post(this.url + "dash/update", { - headers: { 'content-type': 'application/json' }, - body: JSON.stringify([document]) - }); + try { + return rp.post(this.url + "dash/update", { + headers: { 'content-type': 'application/json' }, + body: JSON.stringify([document]) + }); + } catch { } } public async search(query: string) { - const searchResults = JSON.parse(await rp.get(this.url + "dash/select", { - qs: { - q: query - } - })); - const fields = searchResults.response.docs; - const ids = fields.map((field: any) => field.id); - return ids; + try { + const searchResults = JSON.parse(await rp.get(this.url + "dash/select", { + qs: { + q: query + } + })); + const fields = searchResults.response.docs; + const ids = fields.map((field: any) => field.id); + return ids; + } catch { + return []; + } } public async clear() { - return rp.post(this.url + "dash/update", { - body: { - delete: { - query: "*:*" - } - }, - json: true - }); + try { + return rp.post(this.url + "dash/update", { + body: { + delete: { + query: "*:*" + } + }, + json: true + }); + } catch { } } }
\ No newline at end of file |