Javascript Elasticsearch在Jasmine测试中没有及时索引
我目前有一个用于ElasticSearchAPI的测试套件,但似乎所有的测试都是在结果被索引之前运行的,我目前拥有的是Javascript Elasticsearch在Jasmine测试中没有及时索引,javascript,elasticsearch,jasmine,Javascript,elasticsearch,Jasmine,我目前有一个用于ElasticSearchAPI的测试套件,但似乎所有的测试都是在结果被索引之前运行的,我目前拥有的是 const index = `test-${Math.floor(Math.random())}`; const client = new elasticsearch.Client({ host: "localhost:9200", log: "trace", }); const body = {...} beforeAll(async ()
const index = `test-${Math.floor(Math.random())}`;
const client = new elasticsearch.Client({
host: "localhost:9200",
log: "trace",
});
const body = {...}
beforeAll(async () => {
await client.bulk({ body });
});
afterAll(async () => {
await client.indices.delete({
index,
});
});
我以前使用过async和Wait,但现在它们似乎不起作用。如何确保批量命令在测试之前运行?插入文档后需要刷新索引。在插入的文档可搜索之前,有1s的延迟。阅读Elasticsearch文档中的
refresh\u interval
设置和/\u refresh
endoint。插入文档后需要刷新索引。在插入的文档可搜索之前,有1s的延迟。阅读Elasticsearch文档中的refresh\u interval
设置和/\u refresh
endoint。我发现有一种方法可以传递批量参数的刷新参数,但Elasticsearch api上的语法不是很清楚,您是否知道如何将refresh:true添加到批量请求中?通常我只是在(批量)插入后调用/\u refresh
。您可能希望读取对client.index.refresh的调用。谢谢我看到有一种方法可以在批量参数上传递refresh参数,但是elasticsearch api上的语法不是很清楚,您是否知道如何将refresh:true添加到批量请求?通常我只是在(批量)插入之后调用/\u refresh
。您可能想读取对client.indexs.refresh的调用。谢谢