mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-17 05:47:32 +00:00
fix fulltext mapping issue
Signed-off-by: Andrey Platov <andrey@hardcoreeng.com>
This commit is contained in:
parent
9ef7399bd6
commit
7b70a8c7b6
server
@ -80,7 +80,7 @@ export class FullTextIndex extends TxProcessor implements Storage {
|
|||||||
const attributes = this.getFullTextAttributes(tx.objectClass)
|
const attributes = this.getFullTextAttributes(tx.objectClass)
|
||||||
if (attributes === undefined) return {}
|
if (attributes === undefined) return {}
|
||||||
const doc = TxProcessor.createDoc2Doc(tx)
|
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 = {
|
const indexedDoc: IndexedDoc = {
|
||||||
id: doc._id,
|
id: doc._id,
|
||||||
_class: doc._class,
|
_class: doc._class,
|
||||||
|
@ -29,33 +29,38 @@ class ElasticAdapter implements FullTextAdapter {
|
|||||||
async search (
|
async search (
|
||||||
query: SearchQuery
|
query: SearchQuery
|
||||||
): Promise<IndexedDoc[]> {
|
): Promise<IndexedDoc[]> {
|
||||||
const result = await this.client.search({
|
try {
|
||||||
index: this.db,
|
const result = await this.client.search({
|
||||||
body: {
|
index: this.db,
|
||||||
query: {
|
body: {
|
||||||
multi_match: {
|
query: {
|
||||||
query: query.$search,
|
multi_match: {
|
||||||
fields: [
|
query: query.$search,
|
||||||
'content0',
|
fields: [
|
||||||
'content1',
|
'content0',
|
||||||
'content2',
|
'content1',
|
||||||
'content3',
|
'content2',
|
||||||
'content4',
|
'content3',
|
||||||
'content5',
|
'content4',
|
||||||
'content6',
|
'content5',
|
||||||
'content7',
|
'content6',
|
||||||
'content8',
|
'content7',
|
||||||
'content9',
|
'content8',
|
||||||
'attachment.content'
|
'content9',
|
||||||
]
|
'attachment.content'
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
})
|
console.log(result)
|
||||||
console.log(result)
|
const hits = result.body.hits.hits as any[]
|
||||||
const hits = result.body.hits.hits as any[]
|
console.log('hits', hits)
|
||||||
console.log('hits', hits)
|
return hits.map(hit => hit._source)
|
||||||
return hits.map(hit => hit._source)
|
} catch (err) {
|
||||||
|
console.error(JSON.stringify(err, null, 2))
|
||||||
|
return []
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async index (doc: IndexedDoc): Promise<TxResult> {
|
async index (doc: IndexedDoc): Promise<TxResult> {
|
||||||
|
Loading…
Reference in New Issue
Block a user