separate mention category for employees (#5095)

Signed-off-by: Vyacheslav Tumanov <me@slavatumanov.me>
This commit is contained in:
Vyacheslav Tumanov
2024-03-29 18:37:36 +05:00
committed by GitHub
parent 16204edaac
commit 72a93ad388
13 changed files with 56 additions and 52 deletions
+10 -7
View File
@@ -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)
}
+1 -1
View File
@@ -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)
+2 -2
View File
@@ -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,
+2 -2
View File
@@ -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'
+4 -4
View File
@@ -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
}
+1 -1
View File
@@ -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>