mirror of
https://github.com/hcengineering/platform.git
synced 2026-09-09 19:27:44 +02:00
separate mention category for employees (#5095)
Signed-off-by: Vyacheslav Tumanov <me@slavatumanov.me>
This commit is contained in:
@@ -114,16 +114,19 @@ export class FullTextIndex implements WithFind {
|
||||
const old = stDocs.get(cud.objectId as Ref<DocIndexState>)
|
||||
if (cud._class === core.class.TxRemoveDoc && old?.create !== undefined) {
|
||||
// Object created and deleted, skip index
|
||||
stDocs.delete(cud.objectId as Ref<DocIndexState>)
|
||||
continue
|
||||
} else if (old !== undefined) {
|
||||
// Create and update
|
||||
// Skip update
|
||||
continue
|
||||
if (old.removed) continue
|
||||
else {
|
||||
stDocs.set(cud.objectId as Ref<DocIndexState>, {
|
||||
...old,
|
||||
updated: cud._class !== core.class.TxRemoveDoc,
|
||||
removed: cud._class === core.class.TxRemoveDoc
|
||||
})
|
||||
}
|
||||
}
|
||||
stDocs.set(cud.objectId as Ref<DocIndexState>, {
|
||||
updated: cud._class !== core.class.TxRemoveDoc,
|
||||
removed: cud._class === core.class.TxRemoveDoc
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -207,7 +210,7 @@ export class FullTextIndex implements WithFind {
|
||||
const indexedDocMap = new Map<Ref<Doc>, IndexedDoc>()
|
||||
|
||||
for (const doc of docs) {
|
||||
if (this.hierarchy.isDerived(doc._class, baseClass)) {
|
||||
if (doc._class.some((cl) => this.hierarchy.isDerived(cl, baseClass))) {
|
||||
ids.add(doc.id)
|
||||
indexedDocMap.set(doc.id, doc)
|
||||
}
|
||||
|
||||
@@ -152,7 +152,7 @@ export class IndexedFieldStage implements FullTextPipelineStage {
|
||||
const docUpdate: DocumentUpdate<DocIndexState> = {}
|
||||
|
||||
let changes = 0
|
||||
|
||||
docUpdate.mixins = pipeline.hierarchy.findAllMixins(doc as Doc)
|
||||
// Convert previous child fields to just
|
||||
for (const [k] of Object.entries(docState.attributes)) {
|
||||
const { attr, docId, _class } = extractDocKey(k)
|
||||
|
||||
@@ -242,7 +242,7 @@ export class FullTextPushStage implements FullTextPipelineStage {
|
||||
})
|
||||
)
|
||||
|
||||
const allAttributes = pipeline.hierarchy.getAllAttributes(elasticDoc._class)
|
||||
const allAttributes = pipeline.hierarchy.getAllAttributes(doc.objectClass)
|
||||
|
||||
// Include child ref attributes
|
||||
await this.indexRefAttributes(allAttributes, doc, elasticDoc, ctx)
|
||||
@@ -290,7 +290,7 @@ export class FullTextPushStage implements FullTextPipelineStage {
|
||||
export function createElasticDoc (upd: DocIndexState): IndexedDoc {
|
||||
const doc = {
|
||||
id: upd._id,
|
||||
_class: upd.objectClass,
|
||||
_class: [upd.objectClass, ...(upd.mixins ?? [])],
|
||||
modifiedBy: upd.modifiedBy,
|
||||
modifiedOn: upd.modifiedOn,
|
||||
space: upd.space,
|
||||
|
||||
@@ -102,9 +102,9 @@ export const contentStageId = 'cnt-v2b'
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export const fieldStateId = 'fld-v12'
|
||||
export const fieldStateId = 'fld-v13a'
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export const fullTextPushStageId = 'fts-v10b'
|
||||
export const fullTextPushStageId = 'fts-v11a'
|
||||
|
||||
@@ -112,12 +112,12 @@ export async function updateDocWithPresenter (
|
||||
spaceDoc: DocIndexState | undefined
|
||||
}
|
||||
): Promise<void> {
|
||||
const searchPresenter = findSearchPresenter(hierarchy, elasticDoc._class)
|
||||
const searchPresenter = findSearchPresenter(hierarchy, doc.objectClass)
|
||||
if (searchPresenter === undefined) {
|
||||
return
|
||||
}
|
||||
|
||||
const reader = createIndexedReader(elasticDoc._class, hierarchy, doc, {
|
||||
const reader = createIndexedReader(doc.objectClass, hierarchy, doc, {
|
||||
space: refDocs.spaceDoc,
|
||||
attachedTo: refDocs.parentDoc
|
||||
})
|
||||
@@ -156,7 +156,7 @@ export async function updateDocWithPresenter (
|
||||
} else if (prop.provider !== undefined) {
|
||||
const func = await getResource(Object.values(prop.provider)[0] as Resource<any>)
|
||||
const renderProps = await readAndMapProps(reader, prop.config.props)
|
||||
value = func(hierarchy, { _class: elasticDoc._class, ...renderProps })
|
||||
value = func(hierarchy, { _class: doc.objectClass, ...renderProps })
|
||||
} else if (prop.name === 'searchIcon') {
|
||||
value = await readAndMapProps(reader, prop.config.props)
|
||||
}
|
||||
@@ -186,7 +186,7 @@ export function mapSearchResultDoc (hierarchy: Hierarchy, raw: IndexedDoc): Sear
|
||||
iconProps: raw.searchIcon,
|
||||
doc: {
|
||||
_id: raw.id,
|
||||
_class: raw._class
|
||||
_class: raw._class[0]
|
||||
},
|
||||
score: raw._score
|
||||
}
|
||||
|
||||
@@ -183,7 +183,7 @@ export interface EmbeddingSearchOption {
|
||||
*/
|
||||
export interface IndexedDoc {
|
||||
id: Ref<Doc>
|
||||
_class: Ref<Class<Doc>>
|
||||
_class: Ref<Class<Doc>>[]
|
||||
space: Ref<Space>
|
||||
modifiedOn: Timestamp
|
||||
modifiedBy: Ref<Account>
|
||||
|
||||
Reference in New Issue
Block a user