【说站】Python Elasticsearch DSL如何使用
2024-10-10
15
Python Elasticsearch DSL如何使用
1、连接Es:
import elasticsearch es = elasticsearch.Elasticsearch([{'host': '127.0.0.1', 'port': 9200}])
2、先看一下搜索,q 是指搜索内容,空格对 q 查询结果没有影响,size 指定个数,from_ 指定起始位置,filter_path 可以指定需要显示的数据,如显示在最后的结果中的只有 _id 和 _type。
res_3 = es.search(index="bank", q="Holmes", size=1, from_=1) res_4 = es.search(index="bank", q=" 39225 5686 ", size=1000, filter_path=['hits.hits._id', 'hits.hits._type'])
3、根据某个字段查询,可以多个查询条件叠加:
s = Search(using=es, index="index-test").query("match", sip="192.168.1.1") s = s.query("match", dip="192.168.1.2") s = s.excute()
以上就是Python Elasticsearch DSL的使用,希望对大家有所帮助。更多Python学习指路:python基础教程
本文教程操作环境:windows7系统、Python 3.9.1,DELL G3电脑。
更新于:8天前赞一波!
相关文章
- 【说站】python列表的数据类型分析
- 【说站】Python SymPy求极值
- 【说站】python列表如何结合数组使用
- 【说站】python使用f格式化字符串
- 【说站】python函数符号sympy的用法
- 【说站】python format的格式化操作
- 【说站】python无法识别命令的解决
- 【说站】python str.zfill填充字符串
- 【说站】python中str()函数转换字符串
- 【说站】python如何创建操作页面
- 【说站】Python代码中编译是什么
- 【说站】Python找回文子串的方法
- 【说站】python如何读取全部的文件
- 【说站】Python中Exchange发邮件
- 【说站】python导入类的不同方式
- 【说站】python json保存数据的方法
- 【说站】python编写函数的注意点
- 【说站】python使用as指定别名
- 【说站】python函数中返回值的作用
- 【说站】python在函数中传递实参
文章评论
评论问答