gpt4 book ai didi

indexing - 如何在ElasticSearch上自动创建索引?

转载 作者:行者123 更新时间:2023-12-03 02:07:20 25 4
gpt4 key购买 nike

如何在ElasticSearch上自动创建索引?

就像wordpress一样?另请:http://gibrown.wordpress.com/2014/02/06/scaling-elasticsearch-part-2-indexing/

In our case we create one index for every 10 million blogs, with 25 shards per index.



有灯吗

谢谢!

最佳答案

您可以使用自己喜欢的脚本语言进行操作。您首先运行查询以获取索引中文档数的计数。如果超出一定数量,则可以通过Elasticsearch API或curl创建一个新的数量。

这是查找文档数量的查询:

curl --XGET 'http://localhost:9200/youroldindex/_count'

这是索引创建curl:
curl -XPUT 'http://localhost:9200/yournewindex/' -d '{
"settings" : {
"number_of_shards" : 25,
"number_of_replicas" : 2
}
}'

您可能还希望创建别名,以便您的代码始终可以指向单个索引别名,然后在更改热索引时更改别名:

http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-aliases.html

您可能还需要预定义映射:
curl -XPUT 'http://localhost:9200/yournewindex/yournewmapping/_mapping' -d '
{
"document" : {
"properties" : {
"message" : {"type" : "string", "store" : true }
}
}
}
'

Elasticsearch有相当完整的文档,有几个不错的地方:

http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping.html
http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-create-index.html

关于indexing - 如何在ElasticSearch上自动创建索引?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24193816/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com