以前都是按照索引中文档的id进行删除,其实Elasticsearch支持按照条件进行删除操作: 删除索引中某个type的符合条件记录:

curl -XDELETE http://localhost:9200/indexname/typename/_query?pretty -d '{
"query":{
	"filtered":{
		"filter":{
			"bool":{
				"must":{
					"range":{
						"logtime":{
							"gt":"20171214235459",
							"lt":"20171215235959"
						}
					}
				}
			}
		}
	}
}
}';

删除索引中所有的符合条件记录:

curl -XDELETE http://localhost:9200/indexname/_query?pretty -d '{
"query":{
	"filtered":{
		"filter":{
			"bool":{
				"must":{
					"range":{
						"logtime":{
							"gt":"20171214235459",
							"lt":"20171215235959"
						}
					}
				}
			}
		}
	}
}
}';