Elasticsearch Realtime GET支持 [英] Elasticsearch Realtime GET support
问题描述
当我在ES中建立文档索引时,我试图在刷新间隔内访问同一文档,并且搜索未返回结果。是否有实时GET支持,该支持允许一旦索引后就获得文档,而不管索引的刷新率如何。我尝试将refresh_interval减小为500ms(而不是1s),但是我的搜索查询甚至在500ms之前就发生了,进一步减小它不是一个好主意。
When I index a document in ES, I am trying to access the same document within in the refresh interval has passed and the search is not returning the result. Is there a Realtime GET support which allows to get a document once indexed regardless of the "refresh rate" of the index. I tried reducing the refresh_interval to 500ms instead of 1s, but my search query happens even before 500 ms and it is not a good idea to reduce it even further.
推荐答案
索引文档后,您可以立即获取它,而无需等待刷新间隔。
After indexing a document, you can GET it immediately without waiting for the refresh interval.
因此,如果您这样索引新文档
So if you index a new document like this
POST index/type/1
{ "name": "John Doe" }
您可以立即获取它而不必等待使用
You can get it immediately without waiting using
GET index/type/1
但是,如果您进行搜索,则需要等待刷新间隔过去才能检索新文档或调用刷新API。
If you search, however, you'll need to wait for the refresh interval to pass in order to retrieve the new document or call the refresh API.
为了完整性,值得一提的是,在建立索引时,您还可以选择f 立即刷新碎片 ,通过传递 refresh = true
参数,如下所示。但是请注意,这可能会对性能产生不良影响,因此应谨慎使用。
For completeness' sake, it's worth stating that when indexing you also have the option of refreshing the shards immediately, by passing the refresh=true
parameter like below. Note, however, that this can have bad performance implications, so it should be used sparingly.
POST index/type/1?refresh=true
{ "name": "John Doe" }
同样值得注意的是在ES 5中,您可以选择告诉ES 等待刷新,然后从创建调用返回:
Also worth noting that in ES 5, you'll have the option of telling ES to wait for a refresh before returning from the create call:
POST index/type/1?refresh=wait_for
{ "name": "John Doe" }
在这种情况下,请求返回时,可以确保在下一个搜索调用中可以使用新文档。
In this case, once the POST request returns, you're guaranteed that the new document is available in the next search call.
这篇关于Elasticsearch Realtime GET支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!