Skip to content

Commit

Permalink
fixfix update&delete documents that use routing, fixes #235
Browse files Browse the repository at this point in the history
  • Loading branch information
cars10 committed May 23, 2024
1 parent 0357424 commit aecfc81
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 9 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 1.0.8

* fix update&delete documents that use `routing`, fixes [#235](https://github.com/cars10/elasticvue/issues/235)

## 1.0.7

This release contains no changes to elasticvue itself. It is only done to fix build issues with the macos desktop
Expand Down
7 changes: 5 additions & 2 deletions src/composables/components/search/EditDocument.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ type ElasticsearchDocumentMeta = {
_id?: string,
_version?: number,
_primary_term?: number,
_seq_no?: number
_seq_no?: number,
_routing?: string
}

export const useEditDocument = (props: EditDocumentProps, emit: any) => {
Expand Down Expand Up @@ -61,7 +62,8 @@ export const useEditDocument = (props: EditDocumentProps, emit: any) => {
_id: data.value._id,
_version: data.value._version,
_primary_term: data.value._primary_term,
_seq_no: data.value._seq_no
_seq_no: data.value._seq_no,
_routing: data.value._routing
}
}

Expand All @@ -76,6 +78,7 @@ export const useEditDocument = (props: EditDocumentProps, emit: any) => {
index: props._index,
type: props._type,
id: props._id,
routing: props._routing,
params: document.value
},
snackbarOptions: { body: t('search.edit_document.update.growl') }
Expand Down
24 changes: 17 additions & 7 deletions src/services/ElasticsearchAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,18 +190,28 @@ export default class ElasticsearchAdapter {
return this.request('_nodes', 'GET')
}

index ({ index, type, id, params }: { index: string, type: string, id: any, params: any }) {
return this.request(`${index}/${type}/${encodeURIComponent(id)}?refresh=true`, 'PUT', params)
}

get ({ index, type, id, routing }: { index: string, type: string, id: any, routing: any }) {
index ({ index, type, id, routing, params }: {
index: string,
type: string,
id: any,
routing: string,
params: any
}) {
let path = `${index}/${type}/${encodeURIComponent(id)}?refresh=true`
if (routing) path += `&routing=${routing}`
return this.request(path, 'PUT', params)
}

get ({ index, type, id, routing }: { index: string, type: string, id: any, routing?: string }) {
const params: IndexGetArgs = {}
if (routing) params.routing = routing
return this.request(`${index}/${type}/${encodeURIComponent(id)}`, 'GET', params)
}

delete ({ index, type, id }: { index: string, type: string, id: any }) {
return this.request(`${index}/${type}/${encodeURIComponent(id)}?refresh=true`, 'DELETE')
delete ({ index, type, id, routing }: { index: string, type: string, id: any, routing?: string }) {
let path = `${index}/${type}/${encodeURIComponent(id)}?refresh=true`
if (routing) path += `&routing=${routing}`
return this.request(path, 'DELETE')
}

search (params: object, searchIndex?: string | string[]) {
Expand Down

0 comments on commit aecfc81

Please sign in to comment.