当前位置: 首页 > news >正文

郴州网站设计百度百度一下官网

郴州网站设计,百度百度一下官网,盐山县网站建设公司,怎么知道一个网站的权重文章目录 Elasticsearch 查询超过10000 的解决方案 - Python法1#xff1a;修改 设置 max_result_size #xff08;不推荐#xff09;法2#xff1a; scroll 分页法3#xff1a; search_after 分页 Elasticsearch 查询超过10000 的解决方案 - Python 法1#xff1a;修改… 文章目录 Elasticsearch 查询超过10000 的解决方案 - Python法1修改 设置 max_result_size 不推荐法2 scroll 分页法3 search_after 分页 Elasticsearch 查询超过10000 的解决方案 - Python 法1修改 设置 max_result_size 不推荐 # 调大查询窗口大小比如100w 不推荐慎用 PUT test/_settings {index.max_result_window: 1000000 }# 查看 查询最大数 GET test/_settings --- {demo_scroll : {settings : {index : {number_of_shards : 5,provided_name : demo_scroll,max_result_window : 1000000,creation_date : 1680832840425,number_of_replicas : 1,uuid : OLV5W_D9R-WBUaZ_QbGeWA,version : {created : 6082399}}}} }法2 scroll 分页 def getData(self):current_time datetime.datetime.now()one_hour_ago current_time - datetime.timedelta(hours24)current_time_str current_time.strftime(%Y-%m-%d %H:%M:%S)hours_ago_str one_hour_ago.strftime(%Y-%m-%d %H:%M:%S)# 改为从elasticsearch读取数据es Elasticsearch(hostshttp://127.0.0.1/9200,timeout1200)size 10000query_scroll {size: size,query: {range: {create_time.keyword: {gte: hours_ago_str.__str__(),lte: current_time_str.__str__()}}},_source: [ip_address, OS, host, user, create_time],}scroll 10m # 该次连接超时时间设置result []# firstinit_res es.search(indexnac-users, bodyquery_scroll, scrollscroll)scroll_id init_res[_scroll_id]for item in init_res[hits][hits]:result.append({id: item[_id],ip_address: item[_source][ip_address],operating_system: item[_source][OS],hostname: item[_source][host],username: item[_source][user],date_t: item[_source][create_time],})i 0while i 16: # 剩下的数据 一天 24 小时数据估计不会超过 160000res es.scroll(scroll_idscroll_id, scrollscroll)if len(res[hits][hits]) 0:breakfor item in res[hits][hits]:result.append({id: item[_id],ip_address: item[_source][ip_address],operating_system: item[_source][OS],hostname: item[_source][host],username: item[_source][user],date_t: item[_source][create_time],})i i 1# 原始的 # {query: {match_all: {}}, size: 10000}# res es.search(indexnac-users, bodyquery_scroll)## result []# for item in res[hits][hits]:# result.append({# id: item[_id],# ip_address: item[_source][ip_address],# operating_system: item[_source][OS],# hostname: item[_source][host],# username: item[_source][user],# date_t: item[_source][create_time],# })self.data pd.DataFrame(result)法3 search_after 分页 def getData(self):current_time datetime.datetime.now()one_hour_ago current_time - datetime.timedelta(hours24)current_time_str current_time.strftime(%Y-%m-%d %H:%M:%S)hours_ago_str one_hour_ago.strftime(%Y-%m-%d %H:%M:%S)# 改为从elasticsearch读取数据es Elasticsearch(hostshttp://127.0.0.1:9200,timeout1200)size 10000query_scroll {size: size,query: {range: {create_time.keyword: {gte: hours_ago_str.__str__(),lte: current_time_str.__str__()}}},sort: [{create_time.keyword: {order: desc}}],_source: [ip_address, OS, host, user, create_time],}result []init_res es.search(indexnac-users, bodyquery_scroll)if len(init_res[hits][hits]) 0:self.data pd.DataFrame(result)returnsort init_res[hits][hits][0][sort] # 我这里是用时间来排序的所以取到的是时间字段for item in init_res[hits][hits]:result.append({id: item[_id],ip_address: item[_source][ip_address],operating_system: item[_source][OS],hostname: item[_source][host],username: item[_source][user],date_t: item[_source][create_time],})i 0while i 16:query_scroll[search_after] sortres es.search(indexnac-users, bodyquery_scroll)sort res[hits][hits][0][sort]if len(res[hits][hits]) 0:breakfor item in res[hits][hits]:result.append({id: item[_id],ip_address: item[_source][ip_address],operating_system: item[_source][OS],hostname: item[_source][host],username: item[_source][user],date_t: item[_source][create_time],})i i 1self.data pd.DataFrame(result) 还有一个方法是在参考文章2里面提到的track_total_hits但是我测试的时候没起作用目前还不太清楚原因。。。 我看参考文章里说到search_after 分页要比scroll快但是在我的数据上是scroll要快很多不是特别清楚可能我这里的数据暂时只有2w多一点感觉用到search_after 分页需要排序可能是排序的字段的问题时间字段我存的是字符串格式如有可以修改的地方欢迎大家指正~ 有更多可以参考的方法欢迎贴在评论区供大家参考~ 【参考1】https://juejin.cn/post/7224369270141993019 【参考2】https://blog.csdn.net/u011250186/article/details/125483759
http://www.pierceye.com/news/345919/

相关文章:

  • 门户网站 管理系统wordpress 微信图标
  • 广元网站建设广元莱芜论坛二手车
  • 山东省建设工程质量监督网站广州软件合作中心
  • 郑州网站建设怎么样通州建设局网站
  • 免费网站建设福州怎么修改网站主页
  • 深圳企业建站设计公司wordpress不显示样式
  • 外贸网站商城广东省建设协会网站
  • 杭州制作企业公司网站wordpress数据库添加用户
  • 主域名进入网站广告标识标牌制作厂家
  • 网站建设基础流程摘要专题网站建设策划
  • 滁州网站建设电话网站建设与网站优化
  • 慈溪做网站公司哪家好淘宝商城的网站建设
  • 安徽建设厅网站怎么打不开太原网络搭建
  • idea 网站开发最好的免费推广平台
  • 专业排名优化网站怎么建网站教程视频app
  • 全国八大员报名官方网站支付宝小程序开发工具
  • 怎么查看vps网站服务器时间中国建设会计协会网站
  • 门户网站上的广告怎么做深圳服装网站建设
  • 公司网站上线的通知抚州营销型网站建设
  • 中国住房城乡和城乡建设部网站小广告文案
  • 做带字头像的网站wordpress 翻页设置
  • 网站横幅js代码公众号如何申请
  • 找网站建设需要问什么软件物联网平台功能
  • 含山县城市建设有限公司网站成都中高风险地区名单最新
  • 鄂州手机网站建设深圳seo网站设计
  • 网站内容的实现方式建筑设计人才招聘
  • 网站做优化效果怎样iis怎么做网站空间
  • 重庆市建设局网站郑州网站建设哪一家好
  • wordpress指定分类广告金融网站排名优化
  • 美妆网站建设方案陕西网络公司网站建设