Skip to content

Commit

Permalink
feat(reindex): 复制索引
Browse files Browse the repository at this point in the history
  • Loading branch information
jiawei397 committed Jun 19, 2021
1 parent 206b6a1 commit 1c052dd
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
15 changes: 14 additions & 1 deletion examples/conn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,24 @@ const deleteByQuery = async () => {
}
};

const reIndex = async () => {
try {
const info = await client.reindex({
oldIndex: "myindex2",
newIndex: "myindex",
});
console.log(info);
} catch (error) {
console.error(error);
}
};

console.time("ajax");
// await Array.from(new Array(100)).map(ajax);
await create();
// await create();
// await count();
// await update();
await reIndex();

// await deleteById();
// await deleteByQuery();
Expand Down
23 changes: 23 additions & 0 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,29 @@ export class Client {
});
}

reindex(params: {
oldIndex: string | number;
newIndex: string | number;
}) {
const {
oldIndex,
newIndex,
} = params;
const path = "/" + "_reindex";
return ajax({
url: path,
method: "POST",
data: {
source: {
index: oldIndex,
},
dest: {
index: newIndex,
},
},
});
}

close() {
if (this.conn) {
this.conn.close();
Expand Down

0 comments on commit 1c052dd

Please sign in to comment.