diff --git a/server/core/src/fulltext.ts b/server/core/src/fulltext.ts index 2204d80e4f..f60a88de37 100644 --- a/server/core/src/fulltext.ts +++ b/server/core/src/fulltext.ts @@ -80,7 +80,7 @@ export class FullTextIndex extends TxProcessor implements Storage { const attributes = this.getFullTextAttributes(tx.objectClass) if (attributes === undefined) return {} const doc = TxProcessor.createDoc2Doc(tx) - const content = attributes.map(attr => (doc as any)[attr.name]) // buildContent(doc, attributes) // (doc as any)[attribute.name] + const content = attributes.map(attr => ((doc as any)[attr.name] !== null && (doc as any)[attr.name] !== undefined) ? (doc as any)[attr.name].toString() : '') // temporary: getFullTextAttributes should provide string attrs only const indexedDoc: IndexedDoc = { id: doc._id, _class: doc._class, diff --git a/server/elastic/src/adapter.ts b/server/elastic/src/adapter.ts index f5af9042a2..0be44dee9e 100644 --- a/server/elastic/src/adapter.ts +++ b/server/elastic/src/adapter.ts @@ -29,33 +29,38 @@ class ElasticAdapter implements FullTextAdapter { async search ( query: SearchQuery ): Promise { - const result = await this.client.search({ - index: this.db, - body: { - query: { - multi_match: { - query: query.$search, - fields: [ - 'content0', - 'content1', - 'content2', - 'content3', - 'content4', - 'content5', - 'content6', - 'content7', - 'content8', - 'content9', - 'attachment.content' - ] + try { + const result = await this.client.search({ + index: this.db, + body: { + query: { + multi_match: { + query: query.$search, + fields: [ + 'content0', + 'content1', + 'content2', + 'content3', + 'content4', + 'content5', + 'content6', + 'content7', + 'content8', + 'content9', + 'attachment.content' + ] + } } } - } - }) - console.log(result) - const hits = result.body.hits.hits as any[] - console.log('hits', hits) - return hits.map(hit => hit._source) + }) + console.log(result) + const hits = result.body.hits.hits as any[] + console.log('hits', hits) + return hits.map(hit => hit._source) + } catch (err) { + console.error(JSON.stringify(err, null, 2)) + return [] + } } async index (doc: IndexedDoc): Promise {