fix bug and error report
This commit is contained in:
parent
b393f16432
commit
177d8ca3a4
23
cli.ts
23
cli.ts
@ -1,7 +1,7 @@
|
|||||||
import { expandGlob } from 'std/fs/mod.ts';
|
import { expandGlob } from 'std/fs/mod.ts';
|
||||||
import { config } from "std/dotenv/mod.ts";
|
import { config } from "std/dotenv/mod.ts";
|
||||||
import { chunk } from "https://deno.land/std/collections/chunk.ts"
|
import { chunk } from "https://deno.land/std/collections/chunk.ts"
|
||||||
import { Client as ElasticsearchClient } from "https://deno.land/x/elasticsearch@v8.3.3/mod.ts";
|
import { Client as ElasticsearchClient, DocumentsBulkRequest } from "https://deno.land/x/elasticsearch@v8.3.3/mod.ts";
|
||||||
import { Doc, DocParser, readDoc } from './doc_load/load.ts';
|
import { Doc, DocParser, readDoc } from './doc_load/load.ts';
|
||||||
import ProgressBar from 'https://deno.land/x/progress@v1.3.0/mod.ts';
|
import ProgressBar from 'https://deno.land/x/progress@v1.3.0/mod.ts';
|
||||||
import { Command } from "cliffy";
|
import { Command } from "cliffy";
|
||||||
@ -82,19 +82,30 @@ async function bulkIndex(path: string[],{
|
|||||||
}
|
}
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
create: {
|
index: {
|
||||||
_id: doc.author+"/"+doc.name,
|
_id: doc.author+"/"+doc.name,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
doc
|
doc
|
||||||
] as [{ create: { _id: string } }, Doc];
|
] as [{ index: { _id: string } }, Doc];
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
const _ = await client.documents.bulk({
|
const res = await client.documents.bulk({
|
||||||
target: 'github-awesome',
|
target: 'github-awesome',
|
||||||
body: docs.flat(),
|
body: docs.flat(),
|
||||||
});
|
} as DocumentsBulkRequest<Doc>) as {
|
||||||
|
errors: boolean,
|
||||||
|
took: number,
|
||||||
|
items: unknown[]
|
||||||
|
};
|
||||||
|
if (res.errors){
|
||||||
|
if (progressBar){
|
||||||
|
bar.console("error occurs!")
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
console.log("error occurs!")
|
||||||
|
}
|
||||||
|
}
|
||||||
if (progressBar) {
|
if (progressBar) {
|
||||||
bar.render(++i);
|
bar.render(++i);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user