如何使用python查询检查索引是否存在?
我将我的索引作为在查询外部分配的变量传递为: -
i=int(datetime.datetime.now().strftime('%d'))+1
indextring="index"
for m in range (i-10,i):
d = datetime.datetime(2016, 10, m, 18, 00).strftime('%Y-%m-%d')
index1=datestring+d
subfix="_"+datetime.datetime(2016, 10, m, 18, 00).strftime('%Y-%m-%d')
es=Elasticsearch(['localhost:9200'])
res = **es.search(index='{0}'.format(index1)**, doc_type="log",size=10000, from_=0, body={ "query": {
"match": {
....Match condition follows
}
}
}})
Run Code Online (Sandbox Code Playgroud)
现在,某些索引在特定日期不存在,但我希望该过程无论如何都要运行.当索引不存在时,我收到以下错误 - >
elasticsearch.exceptions.NotFoundError:TransportError(404,u'index_not_found_exception')
我不确定异常处理在elasticsearch中是如何工作的.
python elasticsearch elasticsearch-plugin elasticsearch-net elasticsearch-2.0
我知道,我们可以使用curl来增加max_result_window,如:
curl -XPUT "http://localhost:9200/index1/_settings" -d '{ "index" : { "max_result_window" : 500000} }'
Run Code Online (Sandbox Code Playgroud)
但是我如何使用python做同样的事情?
我的代码
es = Elasticsearch(['http://localhost:9200'])
res = es.search(index="index1", doc_type="log",size=10000, from_=0, body={ "query": {
....query starts
}})
Run Code Online (Sandbox Code Playgroud)
我的问题是如何在这里更改max_result_window的设置.
python python-2.6 elasticsearch elasticsearch-plugin spring-data-elasticsearch
有没有“boost/property_tree ”的替代方案?
实际上,我正在尝试删除 C++ 的所有 boost 实现并使用标准库函数。我已经能够找到 boost C++ 的一些其他实现的替代方案,但对于属性树却没有。
不使用 boost 的动机:主要是处理添加的依赖项
bool Processor::init(std::istream& xml, std::istream& rioxml, const std::string& logconfig, const std::string& recoveryConfig) {
boost::property_tree::ptree config;
boost::property_tree::ptree rioconfig;
try {
boost::property_tree::xml_parser::read_xml(xml, config,
boost::property_tree::xml_parser::no_comments);
boost::property_tree::xml_parser::read_xml(rioxml, rioconfig,
boost::property_tree::xml_parser::no_comments);
return Initialize(config, rioconfig, logconfig, recoveryConfig);
}
catch(const boost::property_tree::xml_parser::xml_parser_error& ex){
LOG_ERROR(LOGCAT_DEFAULT, MSGID_UNKNOWN, "Failed to parse business config: " << logconfig);
return false;
}
}
Run Code Online (Sandbox Code Playgroud) 我正在使用Python进行弹性测试.我的代码看起来像这样: -
from elasticsearch import Elasticsearch
if __name__ == '__main__':
index="IndexPosition"
es=Elasticsearch(['https://localhost:8080'])
res = es.search(index='{0}'.format(index), doc_type="log",size=1000, from_=0, body={ "query": {
"match": {
...Match condition
}
}
Run Code Online (Sandbox Code Playgroud)
}})
现在,由于体系结构的变化,弹性搜索中添加了用户身份验证.让我们假设用户名 - 用户和密码 - 通过.如何在查询中传递用户名和密码..?
python python-2.7 elasticsearch elasticsearch-plugin elasticsearch-2.0
我有一个输入字符串,如:-
a=1|b=2|c=3|d=4|e=5 and so on...
Run Code Online (Sandbox Code Playgroud)
我想要做的是从一个很长的相似模式字符串中提取 d=4 部分。有没有办法根据起点定界符和终点定界符获得子字符串?
这样,我可以从 'd=' 开始搜索直到 '|' 提取其价值。欢迎提供任何见解。
python ×4
python-2.7 ×2
boost ×1
c++ ×1
c++11 ×1
python-2.6 ×1
python-3.x ×1
string ×1
substring ×1