[英]Elasticsearch update document without creating new index
I have many existing indices partition by date. 我有许多按日期划分的现有索引。 Eg: index_190901, index_190902,... 例如:index_190901,index_190902,...
And I have an API which takes index_name
and doc_id
as inputs. 我有一个使用index_name
和doc_id
作为输入的API。 User want to update some documents in index by input fields
, index_name
, doc_id
. 用户想通过输入fields
index_name
和doc_id
更新索引中的某些文档。
I'm trying to update document using the following code: 我正在尝试使用以下代码更新文档:
updateRequest.index("invalid_daily_index")
.type("type")
.id("id")
.doc(jsonMap)
It works fine if user input existing index but if user input non-existing index, new index with no document will be created. 如果用户输入现有索引,但如果用户输入不存在的索引,则将创建没有文档的新索引,它可以正常工作。
I know that I can setup auto_create_index but I still want to create index automatically when I insert new documents. 我知道我可以设置auto_create_index,但是当我插入新文档时我仍然想自动创建索引。
Check if index is existed with client.indices.exists(request, RequestOptions.DEFAULT)
is quite expensive. 检查client.indices.exists(request, RequestOptions.DEFAULT)
是否存在索引非常昂贵。 I don't want to check it every request 我不想在每个请求中都对其进行检查
How to make Elasticsearch to not create new index when I use updateRequest
. 当我使用updateRequest
时如何使Elasticsearch不创建新索引。
You can block the option to automaticaly create non existing indices by putting false
to the action.auto_create_index
setting of the cluster 您可以通过将false
设置为集群来阻止自动创建不存在的索引的选项action.auto_create_index
设置
PUT _cluster/settings
{
"persistent" : { "action.auto_create_index” : "false" }
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.