fix overwriting space in elastic doc (#5959)

This commit is contained in:
Vyacheslav Tumanov 2024-07-01 18:30:48 +05:00 committed by GitHub
parent 51028108c7
commit 8d6b583628
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 7 additions and 5 deletions

View File

@ -239,7 +239,7 @@ export function createElasticDoc (upd: DocIndexState): IndexedDoc {
_class: [upd.objectClass, ...(upd.mixins ?? [])],
modifiedBy: upd.modifiedBy,
modifiedOn: upd.modifiedOn,
space: upd.space,
space: [upd.space],
attachedTo: upd.attachedTo,
attachedToClass: upd.attachedToClass
}
@ -321,6 +321,8 @@ function updateDoc2Elastic (
const spaceKey = docKey('space', { _class: core.class.Doc })
if (doc[spaceKey] !== undefined) {
doc.space = doc[spaceKey]
const existsingSpace = Array.isArray(doc.space) ? doc.space : [doc.space]
const newSpaces = Array.isArray(doc[spaceKey]) ? doc[spaceKey] : [doc[spaceKey]]
doc.space = [...existsingSpace, ...newSpaces].filter((it, idx, arr) => arr.indexOf(it) === idx)
}
}

View File

@ -107,4 +107,4 @@ export const fieldStateId = 'fld-v15'
/**
* @public
*/
export const fullTextPushStageId = 'fts-v16'
export const fullTextPushStageId = 'fts-v17'

View File

@ -213,7 +213,7 @@ export interface EmbeddingSearchOption {
export interface IndexedDoc {
id: Ref<Doc>
_class: Ref<Class<Doc>>[]
space: Ref<Space>
space: Ref<Space>[]
modifiedOn: Timestamp
modifiedBy: Ref<Account>
attachedTo?: Ref<Doc>

View File

@ -44,7 +44,7 @@ describe('Elastic Adapter', () => {
_class: ['class1' as Ref<Class<Doc>>],
modifiedBy: 'andrey' as Ref<Account>,
modifiedOn: 0,
space: 'space1' as Ref<Space>,
space: ['space1' as Ref<Space>],
content0: 'hey there!'
}
await adapter.index(doc)