bboss
https://esdoc.bbossgroups.com/#/README
使用的es是6.7.1版本,所以文档也是关于 6.7.1 为准的
https://www.elastic.co/guide/cn/elasticsearch/guide/current/heap-sizing.html
[TOC]
相关链接
- https://www.elastic.co/cn/ 官网
- https://elasticsearch.cn/ es 社区
- https://www.docker.elastic.co docker 镜像链接(推荐直接去下面两个docker hub链接下载,利用阿里云加速会快很多)
- https://hub.docker.com/_/elasticsearch?tab=description elastic search 镜像
- https://hub.docker.com/_/kibana kibana 镜像
- https://www.elastic.co/guide/en/elasticsearch/reference/6.4/docker.html Install Elasticsearch with Docker
- https://www.cnblogs.com/dreamroute/p/8484457.html Elasticsearch-基础介绍及索引原理分析
- https://www.cnblogs.com/bonelee/p/6226386.html lucene底层数据结构——FST,针对field使用列存储,delta encode压缩doc ids数组,LZ4压缩算法
- https://www.infoq.cn/article/database-timestamp-02?utm_source=infoq&utm_medium=related_content_link&utm_campaign=relatedContent_articles_clk 时间序列数据库的秘密 (2)——索引
- http://blog.mikemccandless.com/2014/05/choosing-fast-unique-identifier-uuid.html Changing Bits: Choosing a fast unique identifier (UUID) for Lucene
- https://www.cnblogs.com/yixiao21/p/8407042.html es 概念讲解
- https://www.elastic.co/guide/cn/elasticsearch/guide/current/index.html 《Elasticsearch 权威指南》中文版
- https://elasticsearch.cn/book/elasticsearch_definitive_guide_2.x/ 《Elasticsearch 权威指南》中文版
- https://es.xiaoleilu.com/index.html 《Elasticsearch 权威指南》中文版
- http://wiki.jikexueyuan.com/project/elasticsearch-definitive-guide-cn/ 《Elasticsearch 权威指南》中文版
- https://www.elastic.co/guide/en/elasticsearch/reference/6.7/getting-started.html 6.7的英文文档
- https://www.elastic.co/guide/en/elasticsearch/guide/master/index.html 《Elasticsearch 权威指南》英文版
- https://www.elastic.co/guide/cn/elasticsearch/php/current/index.html PHP API
- https://www.elastic.co/guide/cn/kibana/current/index.html Kibana 用户手册
- https://www.elastic.co/guide/en/elasticsearch/reference/6.7/index.html 6.7搜索api手册
- https://www.elastic.co/guide/en/elasticsearch/client/index.html es 客户端库下载地址
- https://www.elastic.co/guide/en/kibana/current/settings.html kibana 参数配置文档
- https://blog.csdn.net/HcJsJqJSSM/article/details/82969874 es linux 下安装教程
- https://www.cnblogs.com/wangzhuxing/p/9581947.html#_label1_8
- https://qbox.io/blog/ qbox.io es 博客资讯
注意事项
对于网上的教程需要注意对应的版本,如果版本不对,很多操作可能就无效或报错,es的变更很快,需要自己多琢磨。
术语描述
- term - 分词、短语
Demo
https://demo.elastic.co/app/kibana#/dev_tools/console
访问即可在线使用
简介
ElasticSearch是一个基于Lucene的搜索服务器。它提供了一个分布式多用户能力的全文搜索引擎,基于RESTful web接口。Elasticsearch是用Java开发的,并作为Apache许可条款下的开放源码发布,是当前流行的企业级搜索引擎。设计用于云计算中,能够达到实时搜索,稳定,可靠,快速,安装使用方便。
我们建立一个网站或应用程序,并要添加搜索功能,但是想要完成搜索工作的创建是非常困难的。我们希望搜索解决方案要运行速度快,我们希望能有一个零配置和一个完全免费的搜索模式,我们希望能够简单地使用JSON通过HTTP来索引数据,我们希望我们的搜索服务器始终可用,我们希望能够从一台开始并扩展到数百台,我们要实时搜索,我们要简单的多租户,我们希望建立一个云的解决方案。因此我们利用Elasticsearch来解决所有这些问题及可能出现的更多其它问题。
ES概念
https://88250.b3log.org/full-text-search-elasticsearch#b3_solo_h3_8
cluster
代表一个集群,集群中有多个节点,其中有一个为主节点,这个主节点是可以通过选举产生的,主从节点是对于集群内部来说的。es的一个概念就是去中心化,字面上理解就是无中心节点,这是对于集群外部来说的,因为从外部来看es集群,在逻辑上是个整体,你与任何一个节点的通信和与整个es集群通信是等价的。
shards
代表索引分片,es可以把一个完整的索引分成多个分片,这样的好处是可以把一个大的索引拆分成多个,分布到不同的节点上。构成分布式搜索。分片的数量只能在索引创建前指定,并且索引创建后不能更改。
https://www.elastic.co/guide/cn/elasticsearch/guide/current/cluster-health.html
GET /_cluster/health
status
字段指示着当前集群在总体上是否工作正常。它的三种颜色含义如下:
-
green
所有的主分片和副本分片都正常运行。
-
yellow
所有的主分片都正常运行,但不是所有的副本分片都正常运行。
-
red
有主分片没能正常运行。
集群的健康状况为 yellow
则表示全部 主 分片都正常运行(集群可以正常服务所有请求),但是 副本 分片没有全部处在正常状态。 实际上,所有3个副本分片都是 unassigned
—— 它们都没有被分配到任何节点。 在同一个节点上既保存原始数据又保存副本是没有意义的,因为一旦失去了那个节点,我们也将丢失该节点上的所有副本数据。
当前我们的集群是正常运行的,但是在硬件故障时有丢失数据的风险。
replicas
代表索引副本,es可以设置多个索引的副本,副本的作用一是提高系统的容错性,当某个节点某个分片损坏或丢失时可以从副本中恢复。二是提高es的查询效率,es会自动对搜索请求进行负载均衡。
recovery
代表数据恢复或叫数据重新分布,es在有节点加入或退出时会根据机器的负载对索引分片进行重新分配,挂掉的节点重新启动时也会进行数据恢复。
river
代表es的一个数据源,也是其它存储方式(如:数据库)同步数据到es的一个方法。它是以插件方式存在的一个es服务,通过读取river中的数据并把它索引到es中,官方的river有couchDB的,RabbitMQ的,Twitter的,Wikipedia的。
gateway
代表es索引快照的存储方式,es默认是先把索引存放到内存中,当内存满了时再持久化到本地硬盘。gateway对索引快照进行存储,当这个es集群关闭再重新启动时就会从gateway中读取索引备份数据。es支持多种类型的gateway,有本地文件系统(默认),分布式文件系统,Hadoop的HDFS和amazon的s3云存储服务。
discovery.zen
代表es的自动发现节点机制,es是一个基于p2p的系统,它先通过广播寻找存在的节点,再通过多播协议来进行节点之间的通信,同时也支持点对点的交互。
Transport
代表es内部节点或集群与客户端的交互方式,默认内部是使用tcp协议进行交互,同时它支持http协议(json格式)、thrift、servlet、memcached、zeroMQ等的传输协议(通过插件方式集成)。
es概念和关系型数据库概念大概对照
注意 此概念仅仅用于6.x之前的版本
ElasticSearch6.0以上的版本,不支持在同一个Index中拥有不同的Type。
同时官方还声明,将在7.0版本删除Type。
可以参考如下链接信息
- https://blog.csdn.net/EndTheme_Xin/article/details/85103375#commentBox
- https://www.elastic.co/guide/en/elasticsearch/reference/6.0/removal-of-types.html
关系数据库 ⇒ 数据库 ⇒ 表 ⇒ 行 ⇒ 列(Columns)
Elasticsearch ⇒ 索引(Index) ⇒ 类型(type) ⇒ 文档(Docments) ⇒ 字段(Fields)
文档元数据
https://www.elastic.co/guide/cn/elasticsearch/guide/current/_Document_Metadata.html
一个文档不仅仅包含它的数据 ,也包含 元数据 —— 有关 文档的信息。 三个必须的元数据元素如下:
-
_index
文档在哪存放
-
_type
文档表示的对象类别
-
_id
文档唯一标识
_index
一个 索引 应该是因共同的特性被分组到一起的文档集合。 例如,你可能存储所有的产品在索引 products
中,而存储所有销售的交易到索引 sales
中。 虽然也允许存储不相关的数据到一个索引中,但这通常看作是一个反模式的做法。
实际上,在 Elasticsearch 中,我们的数据是被存储和索引在 分片 中,而一个索引仅仅是逻辑上的命名空间, 这个命名空间由一个或者多个分片组合在一起。 然而,这是一个内部细节,我们的应用程序根本不应该关心分片,对于应用程序而言,只需知道文档位于一个 索引内。 Elasticsearch 会处理所有的细节。
我们将在 索引管理 介绍如何自行创建和管理索引,但现在我们将让 Elasticsearch 帮我们创建索引。 所有需要我们做的就是选择一个索引名,这个名字必须小写,不能以下划线开头,不能包含逗号。我们用 website
作为索引名举例。
_type(6.0以上不顶用)
注意:
ElasticSearch6.0以上的版本,不支持在同一个Index中拥有不同的Type。
同时官方还声明,将在7.0版本删除Type。
数据可能在索引中只是松散的组合在一起,但是通常明确定义一些数据中的子分区是很有用的。 例如,所有的产品都放在一个索引中,但是你有许多不同的产品类别,比如 "electronics" 、 "kitchen" 和 "lawn-care"。
这些文档共享一种相同的(或非常相似)的模式:他们有一个标题、描述、产品代码和价格。他们只是正好属于“产品”下的一些子类。
Elasticsearch 公开了一个称为 types (类型)的特性,它允许您在索引中对数据进行逻辑分区。不同 types 的文档可能有不同的字段,但最好能够非常相似。 我们将在 类型和映射 中更多的讨论关于 types 的一些应用和限制。
一个 _type
命名可以是大写或者小写,但是不能以下划线或者句号开头,不应该包含逗号, 并且长度限制为256个字符. 我们使用 blog
作为类型名举例。
_id
ID 是一个字符串, 当它和 _index
以及 _type
组合就可以唯一确定 Elasticsearch 中的一个文档。 当你创建一个新的文档,要么提供自己的 _id
,要么让 Elasticsearch 帮你生成。
自动生成的 ID 是 URL-safe、 基于 Base64 编码且长度为20个字符的 GUID 字符串。 这些 GUID 字符串由可修改的 FlakeID 模式生成,这种模式允许多个节点并行生成唯一 ID ,且互相之间的冲突概率几乎为零。
Index Versus Index Versus Index
你也许已经注意到 索引 这个词在 Elasticsearch 语境中包含多重意思, 所以有必要做一点儿说明:
索引(名词):
如前所述,一个 索引 类似于传统关系数据库中的一个 数据库 ,是一个存储关系型文档的地方。 索引 (index) 的复数词为 indices 或 indexes 。
索引(动词):
索引一个文档 就是存储一个文档到一个 索引 (名词)中以便它可以被检索和查询到。这非常类似于 SQL 语句中的 INSERT
关键词,除了文档已存在时新文档会替换旧文档情况之外。
倒排索引:
关系型数据库通过增加一个 索引 比如一个 B树(B-tree)索引 到指定的列上,以便提升数据检索速度。Elasticsearch 和 Lucene 使用了一个叫做 倒排索引 的结构来达到相同的目的。
默认的,一个文档中的每一个属性都是 被索引 的(有一个倒排索引)和可搜索的。一个没有倒排索引的属性是不能被搜索到的。我们将在 倒排索引 讨论倒排索引的更多细节。
ES中对索引的操作
Index/Create
第一步判断是确定插入的文档是否指定id,如果没有指定id,系统会默认生成一个唯一id。这种情况下,不管index还是create会直接add文档。如果用户指定了id,那么就会走update(这里的update指的是Lucene,并非Elasticsearch中的update),update成本比add要高。
第二步判断,会检查版本号是否冲突,只有正确的版本号才会执行插入,否则会插入失败。通过源码分析可以了解到,获取版本号的这个过程,是通过id来get文档,但无论是index还是create都不会get整个doc的全部内容,只是get出了版号。这也从一定程度上减少了系统开销。
Update
由于Lucene中的update其实就是覆盖替换,并不支持针对特定Field进行修改,Elasticsearch中的update为了实现针对特定字段修改,在Lucene的基础上做了一些改动。
每次update都会调用 InternalEngine 中的get方法,来获取整个文档信息,从而实现针对特定字段进行修改,这也就导致了每次更新要获取一遍原始文档,性能上会有很大影响。所以根据使用场景,有时候使用index会比update好很多。
index时会检查_version。如果插入时没有指定_version,那对于已有的doc,_version会递增,并对文档覆盖。插入时如果指定_version,如果与已有的文档_version不相等,则插入失败,如果相等则覆盖,_version递增。
create时也会检查_version,但是对于已有的文档,不会创建新文档,即插入失败。
Head
Delete
ES中的数据类型
https://www.cnblogs.com/xing901022/p/5471419.html
string(5.0以上不顶用)
ElasticSearch 5.0以后,string类型有重大变更,移除了string类型,string字段被拆分成两种新的数据类型: text用于全文搜索的,而keyword用于关键词搜索。
ElasticSearch字符串将默认被同时映射成text和keyword类型,将会自动创建下面的动态映射(dynamic mappings)
Text:会分词,然后进行索引 、支持模糊、精确查询、不支持聚合
keyword:不进行分词,直接索引、支持模糊、精确查询、支持聚合
可以参考如下链接信息
text
会分词,然后进行索引 、支持模糊、精确查询、不支持聚合
keyword
不进行分词,直接索引、支持模糊、精确查询、支持聚合
integer
float
geo_point
date
https://blog.csdn.net/yesicatt/article/details/53394960
配置参考代码,gte lte 中的日期格式是根据format来的
"timestamp": {
"gte": "2019-04-28 00:00:00",
"lte": "2019-04-29 00:00:00",
"time_zone": "+08:00",
"format": "yyyy-MM-dd HH:mm:ss"
}
查询方式(Query DSL & Filter DSL)
https://blog.lovecoding.org/2018/12/18/es-bool-query/
http://www.cnblogs.com/ghj1976/p/5292740.html
https://www.cnblogs.com/ghj1976/p/5293250.html ElasticSearch 常用的查询过滤语句
注意,默认查询都只查询出10条,聚合也是,需要在聚合里面添加 “size”=100等等
term查询
term
查询被用于精确值 匹配,这些精确值可能是数字、时间、布尔或者那些 not_analyzed
的字符串,如keyword类型
match查询
论你在任何字段上进行的是全文搜索还是精确查询,match
查询是你可用的标准查询。
如果你在一个全文字段上使用 match
查询,在执行查询前,它将用正确的分析器去分析查询字符串
match_phrase查询
should
must
must_not
ES批量操作
为什么是有趣的格式?
当我们早些时候在代价较小的批量操作章节了解批量请求时, 您可能会问自己, "为什么 bulk
API 需要有换行符的有趣格式,而不是发送包装在 JSON 数组中的请求,例如 mget
API?" 。
为了回答这一点,我们需要解释一点背景:在批量请求中引用的每个文档可能属于不同的主分片, 每个文档可能被分配给集群中的任何节点。这意味着批量请求 bulk
中的每个 操作 都需要被转发到正确节点上的正确分片。
如果单个请求被包装在 JSON 数组中,那就意味着我们需要执行以下操作:
- 将 JSON 解析为数组(包括文档数据,可以非常大)
- 查看每个请求以确定应该去哪个分片
- 为每个分片创建一个请求数组
- 将这些数组序列化为内部传输格式
- 将请求发送到每个分片
这是可行的,但需要大量的 RAM 来存储原本相同的数据的副本,并将创建更多的数据结构,Java虚拟机(JVM)将不得不花费时间进行垃圾回收。
相反,Elasticsearch可以直接读取被网络缓冲区接收的原始数据。 它使用换行符字符来识别和解析小的 action/metadata
行来决定哪个分片应该处理每个请求。
这些原始请求会被直接转发到正确的分片。没有冗余的数据复制,没有浪费的数据结构。整个请求尽可能在最小的内存中处理。
https://www.elastic.co/guide/cn/elasticsearch/guide/current/distrib-multi-doc.html
ES分页
https://www.liangzl.com/get-article-detail-115214.html
https://my.oschina.net/u/1787735/blog/3024051
https://www.cnblogs.com/xing901022/archive/2016/03/16/5284902.html
适用于Elasticsearch各个版本(1.x,2.x,5.x,6.x,7.x)的分页案例分享:
https://esdoc.bbossgroups.com/#/search-after
https://esdoc.bbossgroups.com/#/Scroll-SliceScroll-api
https://esdoc.bbossgroups.com/#/from-size
from/size
假设现在你要查询第100页的10条数据,但是对于es来说,from=1000000,size=100,这时 es需要从各个分片上查询出来10000100条数据,然后汇总计算后从其中取出100条。如果有5个分片则需要查询出来5*10000100条数据,如果现在有一个100个查询请求呢,50亿左右的数据,一条数据2KB,就需要9000G左右的内存,什么样的机器能够支持这么庞大的查询,所以如果你在使用es的分页查询过程中,刚开始翻页可能速度比较快,可能到第一百页查询就需要4-5s,翻到1000页以后,直接报错了。
scroll
scroll查询原理是在第一次查询的时候一次性生成一个快照,根据上一次的查询的id来进行下一次的查询,这个就类似于关系型数据库的游标,然后每次滑动都是根据产生的游标id进行下一次查询,这种性能比上面说的分页性能要高出很多,基本都是毫秒级的。 注意:scroll不支持跳页查询。 使用场景:对实时性要求不高的查询,例如微博或者头条滚动查询。
ES的打分模式
运用打分和Boost优化Elasticsearch搜索结果 https://blog.csdn.net/qq_19598855/article/details/50581945
Optimizing Search Results in Elasticsearch with Scoring and Boosting https://qbox.io/blog/optimizing-search-results-in-elasticsearch-with-scoring-and-boosting
虽然es提供了高效的打分函数,但是在电商环境下还是不够用。大多数的用户还是关注排在前几名的结果,所以有灵活的打分机制尤为重要。如果能根据用户的需要展示搜索结果,那么转化率就尤其可观了。
本文中,我们先来看看es默认的评分配置,然后再定制几个评分。本文介绍到的内容可以帮助你做一个用户定制结果的评分。
es默认采用了lucene的评分公式,用正的浮点数score
来表示相关得分。这个score
越高,文档的相关性也就越高。一个查询子句会为每个文档生成一个_score
,计算取决于查询子句的类型。
查询子句服务于不同的目的:模糊查询的_score
取决于原始的搜索词与发现的词的拼写的相似度。词的查询会考虑查到的词的比例。一般情况,相关度都是指计算全文的field的内容与全文query串的相关度。
es中用的标准的相似度算法就是词频/逆文档频率,即tf/idf,考虑了如下要素:
Factor(要素) | Description(描述) |
---|---|
tf | term frequency 词频 |
idf | inverse document frequency 逆文档频率 |
coord | measure of matching on multiple terms 匹配到多个词的处理策略 |
lengthnorm | measure of matching on smaller fields 短field的处理策略 |
querynorm | query normalization factor query标准化因素 |
boost(index) | boost factor at indexing time index阶段的boost要素 |
boost(query) | boost factor at query time query阶段的boost要素 |
上述要素决定了elasticsearch中的决定文档得分的处理要素。
词频(TF):词频是对一个词在文档的内容中出现次数的计量。如果出现次数多,得分就高,该文档与查询相关的可能性就高。
逆文档频率(IDF):逆文档频率是对搜索的词在文档集中出现的频率的衡量。如果一个搜索词在很多文档中都普遍的出现,(这个词)的得分就比较低。那种稀有词如果在文档中频繁出现,会把评分值boost的较高。
共现因子(Coord):共现因子是对出现多个搜索词的衡量,query中的词共现的越多,整体的得分就越高。比如搜索这两个词“woolen(羊毛)”&“jacket(夹克)”。两个词放在一起搜也没啥问题:在内部会转化为bool查询,每个词都会单独的去搜索。两个词都包含的文档比那些只包含一个词的文档得分高。如果你给query的权重是2,那么两个词都包含的词的coord是22 = 4。只包含一个词的coord权重就是2 1 = 2。
长度标准化(lengthnorm):会衡量短field的匹配,给出更高的权重。
译者:lucene考虑了文章的长度,因为考虑到更长的文章会包含更多的词,从而通过lengthnorm进行标准化。所以lucene会跟偏向于短标题。
比如:title,短文本的标准化因子0.5,而较长的标题可能只有0.01。所以标准化因子可能极大的影响得分。
ES常用插件
ES-IKAnalyzer插件
https://github.com/medcl/elasticsearch-analysis-ik/releases
https://www.cnblogs.com/wangzhuxing/p/9351245.html
https://www.jianshu.com/p/914f102bc174 中文分词优化
elasticsearch-sql
http://www.cnblogs.com/kangoroo/p/7273493.html
https://github.com/NLPchina/elasticsearch-sql
es配置
setting
mapping
aliases
https://blog.csdn.net/changong28/article/details/38424143
悲观并发控制
这种方法被关系型数据库广泛使用,它假定有变更冲突可能发生,因此阻塞访问资源以防止冲突。 一个典型的例子是读取一行数据之前先将其锁住,确保只有放置锁的线程能够对这行数据进行修改。
乐观并发控制
https://www.elastic.co/guide/cn/elasticsearch/guide/current/optimistic-concurrency-control.html
Elasticsearch 中使用的这种方法假定冲突是不可能发生的,并且不会阻塞正在尝试的操作。 然而,如果源数据在读写当中被修改,更新将会失败。应用程序接下来将决定该如何解决冲突。 例如,可以重试更新、使用新的数据、或者将相关情况报告给用户。
docker run
docker network create somenetwork
docker run -d --name elasticsearch --net es_network -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" elasticsearch:6.7.1
docker run -d --name kibana --net es_network -p 5601:5601 kibana:6.7.1
docker compose
单机开发版develop
docker-compose.develop.yml
version: '3.3'
services:
elasticsearch:
hostname: elasticsearch
image: elasticsearch:6.7.1
environment:
- discovery.type=single-node
ports:
- target: 9200
published: 9200
protocol: tcp
mode: host
- target: 9300
published: 9300
protocol: tcp
mode: host
networks:
- es_network
kibana:
hostname: kibana
image: kibana:6.7.1
ports:
- target: 5601
published: 5601
protocol: tcp
mode: host
networks:
- es_network
elastichd:
hostname: elastichd
container_name: elastichd
image: containerize/elastichd
ports:
- target: 9800
published: 9800
protocol: tcp
mode: host
networks:
- es_network
networks:
es_network:
命令
docker-compose -f .\docker-compose.develop.yml up -d --remove-orphans
集群开发版
docker-compose.cluster.yml
version: '3.3'
services:
elasticsearch:
image: elasticsearch:6.7.1
hostname: elasticsearch
container_name: elasticsearch
environment:
- cluster.name=docker-cluster
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- es_data1:/usr/share/elasticsearch/data
networks:
- es_network
elasticsearch2:
image: elasticsearch:6.7.1
hostname: elasticsearch2
container_name: elasticsearch2
environment:
- cluster.name=docker-cluster
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
- "discovery.zen.ping.unicast.hosts=elasticsearch"
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- es_data2:/usr/share/elasticsearch/data
networks:
- es_network
kibana:
hostname: kibana
container_name: kibana
image: kibana:6.7.1
ports:
- target: 5601
published: 5601
protocol: tcp
mode: host
networks:
- es_network
volumes:
es_data1:
driver: local
es_data2:
driver: local
networks:
es_network:
上面的docker 配置集群目前不行
所以需要把环境变量去掉,改为在配置文件里面调整
cat /home/elasticsearch-6.3.1/config/elasticsearch.yml
# Set the bind address to a specific IP (IPv4 or IPv6):
# 允许访问的ip,0.0.0.0表示任意ip可以访问
network.host: 0.0.0.0
# Set a custom port for HTTP:
# 对外端口
http.port: 9200
# Pass an initial list of hosts to perform discovery when new node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
# 集群其他节点IP,只有一个节点写本机ip
discovery.zen.ping.unicast.hosts: ["host1", "host2"]
https://www.cnblogs.com/wangzhuxing/p/9351245.html
命令
docker-compose -f .\docker-compose.cluster.yml up -d --remove-orphans
elastic search 详情
对外开放默认端口为 9200,9300
9300 给 java api用,9200 给其他客户端用。
Java API
如果你正在使用 Java,在代码中你可以使用 Elasticsearch 内置的两个客户端:
-
节点客户端(Node client)
节点客户端作为一个非数据节点加入到本地集群中。换句话说,它本身不保存任何数据,但是它知道数据在集群中的哪个节点中,并且可以把请求转发到正确的节点。
-
传输客户端(Transport client)
轻量级的传输客户端可以将请求发送到远程集群。它本身不加入集群,但是它可以将请求转发到集群中的一个节点上。
两个 Java 客户端都是通过 9300 端口并使用 Elasticsearch 的原生 传输 协议和集群交互。集群中的节点通过端口 9300 彼此通信。如果这个端口没有打开,节点将无法形成一个集群。
RESTful API with JSON over HTTP
所有其他语言可以使用 RESTful API 通过端口 9200 和 Elasticsearch 进行通信,你可以用你最喜爱的 web 客户端访问 Elasticsearch 。事实上,正如你所看到的,你甚至可以使用 curl
命令来和 Elasticsearch 交互。
Elasticsearch 为以下语言提供了官方客户端 --Groovy、JavaScript、.NET、 PHP、 Perl、 Python 和 Ruby--还有很多社区提供的客户端和插件,所有这些都可以在 Elasticsearch Clients 中找到。
一个 Elasticsearch 请求和任何 HTTP 请求一样由若干相同的部件组成:
curl -X<VERB> '<PROTOCOL>://<HOST>:<PORT>/<PATH>?<QUERY_STRING>' -d '<BODY>'
被 < > 标记的部件: |
占位符 | 说明 |
---|---|---|
VERB |
适当的 HTTP 方法 或 谓词 : GET 、 POST 、 PUT 、 HEAD 或者 DELETE 。 |
|
PROTOCOL |
http 或者 https (如果你在 Elasticsearch 前面有一个 https 代理) |
|
HOST |
Elasticsearch 集群中任意节点的主机名,或者用 localhost 代表本地机器上的节点。 |
|
PORT |
运行 Elasticsearch HTTP 服务的端口号,默认是 9200 。 |
|
PATH |
API 的终端路径(例如 _count 将返回集群中文档数量)。Path 可能包含多个组件,例如:_cluster/stats 和 _nodes/stats/jvm 。 |
|
QUERY_STRING |
任意可选的查询字符串参数 (例如 ?pretty 将格式化地输出 JSON 返回值,使其更容易阅读) |
|
BODY |
一个 JSON 格式的请求体 (如果请求需要的话) |
例如,计算集群中文档的数量,我们可以用这个:
curl -XGET 'http://localhost:9200/_count?pretty' -d '
{
"query": {
"match_all": {}
}
}
'
Elasticsearch 返回一个 HTTP 状态码(例如:200 OK
)和(除HEAD
请求)一个 JSON 格式的返回值。前面的 curl
请求将返回一个像下面一样的 JSON 体:
{
"count" : 0,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
}
}
在返回结果中没有看到 HTTP 头信息是因为我们没有要求curl
显示它们。想要看到头信息,需要结合 -i
参数来使用 curl
命令:
curl -i -XGET 'localhost:9200/'
在书中剩余的部分,我们将用缩写格式来展示这些 curl
示例,所谓的缩写格式就是省略请求中所有相同的部分,例如主机名、端口号以及 curl
命令本身。而不是像下面显示的那样用一个完整的请求:
curl -XGET 'localhost:9200/_count?pretty' -d '
{
"query": {
"match_all": {}
}
}'
我们将用缩写格式显示:
GET /_count
{
"query": {
"match_all": {}
}
}
拷贝为 CURL在 SENSE 中查看
事实上, Sense 控制台 也使用这样相同的格式。如果你正在阅读这本书的在线版本,可以通过点击 Sense 链接视图在 Sense 上打开和运行示例代码。
详情参见链接:https://www.elastic.co/guide/cn/elasticsearch/guide/current/_talking_to_elasticsearch.html
kibana 详情
https://www.elastic.co/guide/en/kibana/current/settings.html kibana 参数配置文档
可视化 ui 管理界面
Kibana can be accessed by browser via http://localhost:5601
or http://host-ip:5601
linux下安装位置
/usr/share/kibana
x-pack
安装指令
kibana-plugin install x-pack
注意 6.3版本以后的不需要安装,因为 Elastic Stack 默认集成了x-pack
就算安装也会提示如下错误:
Plugin installation was unsuccessful due to error "Kibana now contains X-Pack by default, there is no longer any need to install it as it is already present."
运用打分和Boost优化Elasticsearch搜索结果
运用打分和Boost优化Elasticsearch搜索结果 https://blog.csdn.net/qq_19598855/article/details/50581945
Optimizing Search Results in Elasticsearch with Scoring and Boosting https://qbox.io/blog/optimizing-search-results-in-elasticsearch-with-scoring-and-boosting
来自Optimizing Search Results in Elasticsearch with Scoring and Boosting 作者:Neil Alex 2015/03/18
虽然es提供了高效的打分函数,但是在电商环境下还是不够用。大多数的用户还是关注排在前几名的结果,所以有灵活的打分机制尤为重要。如果能根据用户的需要展示搜索结果,那么转化率就尤其可观了。
本文中,我们先来看看es默认的评分配置,然后再定制几个评分。本文介绍到的内容可以帮助你做一个用户定制结果的评分。
es默认采用了lucene的评分公式,用正的浮点数_score
来表示相关得分。这个_score
越高,文档的相关性也就越高。一个查询子句会为每个文档生成一个_score
,计算取决于查询子句的类型。
查询子句服务于不同的目的:模糊查询的_score
取决于原始的搜索词与发现的词的拼写的相似度。词的查询会考虑查到的词的比例。一般情况,相关度都是指计算全文的field的内容与全文query串的相关度。
es中用的标准的相似度算法就是词频/逆文档频率,即tf/idf,考虑了如下要素:
要素 | 描述 |
---|---|
tf | 词频 |
idf | 逆文档频率 |
coord | 匹配到多个词的处理策略 |
lengthnorm | 短field的处理策略 |
querynorm | query标准化因素 |
boost(index) | index阶段的boost要素 |
boost(query) | query阶段的boost要素 |
上述要素决定了elasticsearch中的决定文档得分的处理要素。
词频(TF):词频是对一个词在文档的内容中出现次数的计量。如果出现次数多,得分就高,该文档与查询相关的可能性就高。
逆文档频率(IDF):逆文档频率是对搜索的词在文档集中出现的频率的衡量。如果一个搜索词在很多文档中都普遍的出现,(这个词)的得分就比较低。那种稀有词如果在文档中频繁出现,会把评分值boost的较高。
共现因子(Coord):共现因子是对出现多个搜索词的衡量,query中的词共现的越多,整体的得分就越高。比如搜索这两个词“woolen(羊毛)”&“jacket(夹克)”。两个词放在一起搜也没啥问题:在内部会转化为bool查询,每个词都会单独的去搜索。两个词都包含的文档比那些只包含一个词的文档得分高。如果你给query的权重是2,那么两个词都包含的词的coord是22 = 4。只包含一个词的coord权重就是2 1 = 2。
长度标准化(lengthnorm):会衡量短field的匹配,给出更高的权重。
译者:lucene考虑了文章的长度,因为考虑到更长的文章会包含更多的词,从而通过lengthnorm进行标准化。所以lucene会跟偏向于短标题。
比如:title,短文本的标准化因子0.5,而较长的标题可能只有0.01。所以标准化因子可能极大的影响得分。
比如,如果搜索词在title中,那它比在content中更相关,得分更高。
query标准化(querynorm):虽然不直接与文档相关度相关,querynorm在你对query类型的组合时,可以对query进行衡量。
Index时boost(index time boost)&Query时boost(query time boost):可以在索引时和查询时进行boost。对特定的field进行boost时,会让得分的计算更加明显。
Lucene的评分计算:默认的es的得分算法是布尔检索与空间向量模型的组合。通过布尔模型的文档会通过空间向量模型进行下一步的评分计算。
得分公式如下:
$$
score(q,d)=score(q,d)=
queryNorm(q)∗coord(q,d)∗∑t∈q(tf(t∈q)∗idf(t)2∗t.getBoost()∗norm(t,d))queryNorm(q)∗coord(q,d)∗∑t∈q(tf(t∈q)∗idf(t)2∗t.getBoost()∗norm(t,d))
$$
我们来看看我们如何用这些要素来计算一个文档的得分,首先我们先来看看调试es中query的工具。打开query中的explain,你就可以得到上述的得分因素中的每一个详细解释,以及该文档的最终得分。我们不推荐在最终的产品中使用这个结果,但是你在开发中debug,调整query时还是很有用的。
调整_score
最有用的工具就是function_score
。
实际上es为每个匹配提供了很多得分计算方法。可以使用custom_score
以及脚本来获取特定数字域的得分。例如:
“script”:
“_score * doc[‘my_numeric_field’].value”
我们这里my_numeric_field
乘上默认的_score
进行加权。也可以使用custom_filers_score_query
,可以应用过滤器来限制结果集,在用脚本或者boost来为过滤后的文档分配一个boost。相似的也可以应用custom_boost_factor
来乘上默认的打分来给query一个boost的值。在es的0.19.0版本中,有一个新query可以把所有的要素都融合进function_score
。再附加上内嵌的功能,用脚本可以实现更多功能。用function_score
你首先需要定义一个query,然后就可以使用任意的过滤器了。使用过滤器来限制达到你标准的结果。这样就可以不计算那些你不想要结果得分了。如果你选择这种boost模式,你可以通过你定制的函数决定最后的得分。你可以用默认的结果直接代替得分,或者通过你函数的计算来乘上默认的搜索结果。
Elasticsearch提供了结合多个函数结果来计算得分的多种函数的能力。也有多种用 function_score
query来计算多找要素的方法,其中有:时间要素、距离特定点的距离、热门程度等。我们现在在来进一步的深入了解给数据集的做相关度的tuning。
script_score提供了通过script表达式来定义一个评分函数的功能。再加上field_value_factor,你可以获得一个特定field的值,这样获得的这个field的值可以直接参与最终的评分的计算。DECAY_FUNCTION提供得分的衰减模式。
例子1:你想找到一个地理坐标点的距离,5km以内的点权重要是5km外的点的权重的三倍。
例子2:考虑发布时间的文档,比如一个文档的头15天得分为7,发布时间为25的话,得分就应该为3。这样的例子都可以使用DECAY_FUNCTION以及加权函数和随机函数。你也可以写一个定制函数来应用上述的那些函数,并可以在此基础上进行定制。
如上述,我们可以运用多种函数来计算一个得分值,然后再用score_mode
和boost_mode
来融合这些函数的输出。score_mode
定义了你定义的单独的函数怎样融合,boost_mode
定义了你如何给默认的得分一个特定的得分函数或者连续加或乘所有的函数结果。如下列出了boost_mode
和 score_mode
。
boost_mode的功能
多种query得分以及函数得分(默认的)的加和加上函数得分的平均,平均了函数得分,定制的得分的最小值首先代替query得分,函数得分的最大值代替query得分和函数得分的大者。
score_mode中的可选项
模式 | 功能 |
---|---|
multiply | 乘函数打分值(默认) |
sum | 加和 |
avg | 平均值 |
first | 应用filter匹配上的第一个函数值 |
min | 采用函数得分的最小值 |
max | 采用函数得分的最大值 |
我们现在来做一个完整的例子,我们自己写一个按照热度递减的排序。首先索引得分,假定一个特定的item如果他的热度高,对应的排序就较高。简单的方式就是定义一个function_score
query,用内建的field_value_factor
函数来介入得分:
POST /ecomercedata/gadgets/_search
{
"explain": true,
"query": {
"function_score": {
"query": {
"match_all": {}
},
"functions": [
{
"field_value_factor": {
"field": "rating"
}
}
],
"boost_mode": "multiply"
}
}
}
我们来review一下上述的代码,t.getboost()
以及boost
不可见,因为他们都在querynorm中。可以尝试给特定的field加boost值,可以看到匹配到的在explanation中有更高的querynorm
得分。
{{ "took": 22,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"failed": 0
},
"hits": {
"total": 9,
"max_score": 9,
"hits": [
{
"_shard": 0,
"_node": "477kWUQVR2eiLpIQEN4vFw",
"_index": "ecomercedata",
"_type": "gadgets",
"_id": "nKk9DfRnTDyUU80cepXRrw",
"_score": 9,
"_source": {
"name": "MacBookPro",
"category": "Laptop",
"brand": "Apple",
"rating": 9,
"prize": 1299,
"piecesSold": 9500,
"dateOfRelease": "2005-02-01"
},
"_explanation": {
"value": 9,
"description": "function score, product of:",
"details": [
{
"value": 1,
"description": "ConstantScore(*:*), product of:",
"details": [
{
"value": 1,
"description": "boost"
},
{
"value": 1,
"description": "queryNorm"
}
]
},
{
"value": 9,
"description": "Math.min of",
"details": [
{
"value": 9,
"description": "function score, score mode [multiply]",
"details": [
{
"value": 9,
"description": "function score, product of:",
"details": [
{
"value": 1,
"description": "match filter: *:*"
},
{
"value": 9,
"description": "field value function: (doc['rating'].value * factor=1.0)",
"details": [
{
"value": 1,
"description": "ConstantScore(*:*), product of:",
"details": [
{
"value": 1,
"description": "boost"
},
{
"value": 1,
"description": "queryNorm"
}
]
}
]
}
]
}
]
},
{
"value": 3.4028235e+38,
"description": "maxBoost"
}
]
},
{
"value": 1,
"description": "queryBoost"
}
]
}
},
{
"_shard": 0,
"_node": "477kWUQVR2eiLpIQEN4vFw",
"_index": "ecomercedata",
"_type": "gadgets",
"_id": "KNycQwC5TcSmhXPBdKgW3g",
"_score": 9,
"_source": {
"name": "Ipad",
"category": "Tablet",
"brand": "Apple",
"rating": 9,
"prize": 600,
"piecesSold": 9500,
"dateOfRelease": "2005-07-01"
},
"_explanation": {
"value": 9,
"description": "function score, product of:",
"details": [
{
"value": 1,
"description": "ConstantScore(*:*), product of:",
"details": [
{
"value": 1,
"description": "boost"
},
{
"value": 1,
"description": "queryNorm"
}
]
},
{
"value": 9,
"description": "Math.min of",
"details": [
{
"value": 9,
"description": "function score, score mode [multiply]",
"details": [
{
"value": 9,
"description": "function score, product of:",
"details": [
{
"value": 1,
"description": "match filter: *:*"
},
{
"value": 9,
"description": "field value function: (doc['rating'].value * factor=1.0)",
"details": [
{
"value": 1,
"description": "ConstantScore(*:*), product of:",
"details": [
{
"value": 1,
"description": "boost"
},
{
"value": 1,
"description": "queryNorm"
}
]
}
]
}
]
}
]
},
{
"value": 3.4028235e+38,
"description": "maxBoost"
}
]
},
{
"value": 1,
"description": "queryBoost"
}
]
}
},
{
"_shard": 0,
"_node": "477kWUQVR2eiLpIQEN4vFw",
"_index": "ecomercedata",
"_type": "gadgets",
"_id": "IfTr4n90Tbez-t26Iu6JCg",
"_score": 8,
"_source": {
"name": "MacBookAir",
"category": "Laptop",
"brand": "Apple",
"rating": 8,
"prize": 1099,
"piecesSold": 8700,
"dateOfRelease": "2006-05-01"
},
"_explanation": {
"value": 8,
"description": "function score, product of:",
"details": [
{
"value": 1,
"description": "ConstantScore(*:*), product of:",
"details": [
{
"value": 1,
"description": "boost"
},
{
"value": 1,
"description": "queryNorm"
}
]
},
{
"value": 8,
"description": "Math.min of",
"details": [
{
"value": 8,
"description": "function score, score mode [multiply]",
"details": [
{
"value": 8,
"description": "function score, product of:",
"details": [
{
"value": 1,
"description": "match filter: *:*"
},
{
"value": 8,
"description": "field value function: (doc['rating'].value * factor=1.0)",
"details": [
{
"value": 1,
"description": "ConstantScore(*:*), product of:",
"details": [
{
"value": 1,
"description": "boost"
},
{
"value": 1,
"description": "queryNorm"
}
]
}
]
}
]
}
]
},
{
"value": 3.4028235e+38,
"description": "maxBoost"
}
]
},
{
"value": 1,
"description": "queryBoost"
}
]
}
},
{
"_shard": 0,
"_node": "477kWUQVR2eiLpIQEN4vFw",
"_index": "ecomercedata",
"_type": "gadgets",
"_id": "90hw7WyKSu2X0YAk3NBTMQ",
"_score": 8,
"_source": {
"name": "ATIVBook",
"category": "Laptop",
"brand": "Samsung",
"rating": 8,
"prize": 1899,
"piecesSold": 3500,
"dateOfRelease": "2014-05-01"
},
"_explanation": {
"value": 8,
"description": "function score, product of:",
"details": [
{
"value": 1,
"description": "ConstantScore(*:*), product of:",
"details": [
{
"value": 1,
"description": "boost"
},
{
"value": 1,
"description": "queryNorm"
}
]
},
{
"value": 8,
"description": "Math.min of",
"details": [
{
"value": 8,
"description": "function score, score mode [multiply]",
"details": [
{
"value": 8,
"description": "function score, product of:",
"details": [
{
"value": 1,
"description": "match filter: *:*"
},
{
"value": 8,
"description": "field value function: (doc['rating'].value * factor=1.0)",
"details": [
{
"value": 1,
"description": "ConstantScore(*:*), product of:",
"details": [
{
"value": 1,
"description": "boost"
},
{
"value": 1,
"description": "queryNorm"
}
]
}
]
}
]
}
]
},
{
"value": 3.4028235e+38,
"description": "maxBoost"
}
]
},
{
"value": 1,
"description": "queryBoost"
}
]
}
},
{
"_shard": 0,
"_node": "477kWUQVR2eiLpIQEN4vFw",
"_index": "ecomercedata",
"_type": "gadgets",
"_id": "xquXInoJSSOnPwuzrOTO8A",
"_score": 8,
"_source": {
"name": "GalaxyTab",
"category": "Tablet",
"brand": "Samsung",
"rating": 8,
"prize": 550,
"piecesSold": 8500,
"dateOfRelease": "2007-07-01"
},
"_explanation": {
"value": 8,
"description": "function score, product of:",
"details": [
{
"value": 1,
"description": "ConstantScore(*:*), product of:",
"details": [
{
"value": 1,
"description": "boost"
},
{
"value": 1,
"description": "queryNorm"
}
]
},
{
"value": 8,
"description": "Math.min of",
"details": [
{
"value": 8,
"description": "function score, score mode [multiply]",
"details": [
{
"value": 8,
"description": "function score, product of:",
"details": [
{
"value": 1,
"description": "match filter: *:*"
},
{
"value": 8,
"description": "field value function: (doc['rating'].value * factor=1.0)",
"details": [
{
"value": 1,
"description": "ConstantScore(*:*), product of:",
"details": [
{
"value": 1,
"description": "boost"
},
{
"value": 1,
"description": "queryNorm"
}
]
}
]
}
]
}
]
},
{
"value": 3.4028235e+38,
"description": "maxBoost"
}
]
},
{
"value": 1,
"description": "queryBoost"
}
]
}
},
{
"_shard": 0,
"_node": "477kWUQVR2eiLpIQEN4vFw",
"_index": "ecomercedata",
"_type": "gadgets",
"_id": "qnSLIKIWTsyjRdM0dNcrWg",
"_score": 8,
"_source": {
"name": "Iphone",
"category": "Mobile",
"brand": "Apple",
"rating": 8,
"prize": 60,
"piecesSold": 28000,
"dateOfRelease": "2002-03-01"
},
"_explanation": {
"value": 8,
"description": "function score, product of:",
"details": [
{
"value": 1,
"description": "ConstantScore(*:*), product of:",
"details": [
{
"value": 1,
"description": "boost"
},
{
"value": 1,
"description": "queryNorm"
}
]
},
{
"value": 8,
"description": "Math.min of",
"details": [
{
"value": 8,
"description": "function score, score mode [multiply]",
"details": [
{
"value": 8,
"description": "function score, product of:",
"details": [
{
"value": 1,
"description": "match filter: *:*"
},
{
"value": 8,
"description": "field value function: (doc['rating'].value * factor=1.0)",
"details": [
{
"value": 1,
"description": "ConstantScore(*:*), product of:",
"details": [
{
"value": 1,
"description": "boost"
},
{
"value": 1,
"description": "queryNorm"
}
]
}
]
}
]
}
]
},
{
"value": 3.4028235e+38,
"description": "maxBoost"
}
]
},
{
"value": 1,
"description": "queryBoost"
}
]
}
},
{
"_shard": 0,
"_node": "477kWUQVR2eiLpIQEN4vFw",
"_index": "ecomercedata",
"_type": "gadgets",
"_id": "uq5kDPYlTQC6mRBJDtS2lQ",
"_score": 8,
"_source": {
"name": "Xperia",
"category": "Mobile",
"brand": "Sony",
"rating": 8,
"prize": 70,
"piecesSold": 24000,
"dateOfRelease": "2004-03-01"
},
"_explanation": {
"value": 8,
"description": "function score, product of:",
"details": [
{
"value": 1,
"description": "ConstantScore(*:*), product of:",
"details": [
{
"value": 1,
"description": "boost"
},
{
"value": 1,
"description": "queryNorm"
}
]
},
{
"value": 8,
"description": "Math.min of",
"details": [
{
"value": 8,
"description": "function score, score mode [multiply]",
"details": [
{
"value": 8,
"description": "function score, product of:",
"details": [
{
"value": 1,
"description": "match filter: *:*"
},
{
"value": 8,
"description": "field value function: (doc['rating'].value * factor=1.0)",
"details": [
{
"value": 1,
"description": "ConstantScore(*:*), product of:",
"details": [
{
"value": 1,
"description": "boost"
},
{
"value": 1,
"description": "queryNorm"
}
]
}
]
}
]
}
]
},
{
"value": 3.4028235e+38,
"description": "maxBoost"
}
]
},
{
"value": 1,
"description": "queryBoost"
}
]
}
},
{
"_shard": 0,
"_node": "477kWUQVR2eiLpIQEN4vFw",
"_index": "ecomercedata",
"_type": "gadgets",
"_id": "YdtFFxICR-6nMxNcQmWoaQ",
"_score": 6,
"_source": {
"name": "Inspiron",
"category": "Laptop",
"brand": "Dell",
"rating": 6,
"prize": 700,
"piecesSold": 4600,
"dateOfRelease": "2008-03-01"
},
"_explanation": {
"value": 6,
"description": "function score, product of:",
"details": [
{
"value": 1,
"description": "ConstantScore(*:*), product of:",
"details": [
{
"value": 1,
"description": "boost"
},
{
"value": 1,
"description": "queryNorm"
}
]
},
{
"value": 6,
"description": "Math.min of",
"details": [
{
"value": 6,
"description": "function score, score mode [multiply]",
"details": [
{
"value": 6,
"description": "function score, product of:",
"details": [
{
"value": 1,
"description": "match filter: *:*"
},
{
"value": 6,
"description": "field value function: (doc['rating'].value * factor=1.0)",
"details": [
{
"value": 1,
"description": "ConstantScore(*:*), product of:",
"details": [
{
"value": 1,
"description": "boost"
},
{
"value": 1,
"description": "queryNorm"
}
]
}
]
}
]
}
]
},
{
"value": 3.4028235e+38,
"description": "maxBoost"
}
]
},
{
"value": 1,
"description": "queryBoost"
}
]
}
},
{
"_shard": 0,
"_node": "477kWUQVR2eiLpIQEN4vFw",
"_index": "ecomercedata",
"_type": "gadgets",
"_id": "MjSPJ9hqTbu8U6PfyMrl4A",
"_score": 6,
"_source": {
"name": "Lumia",
"category": "Mobile",
"brand": "Nokia",
"rating": 6,
"prize": 50,
"piecesSold": 12000,
"dateOfRelease": "2009-03-01"
},
"_explanation": {
"value": 6,
"description": "function score, product of:",
"details": [
{
"value": 1,
"description": "ConstantScore(*:*), product of:",
"details": [
{
"value": 1,
"description": "boost"
},
{
"value": 1,
"description": "queryNorm"
}
]
},
{
"value": 6,
"description": "Math.min of",
"details": [
{
"value": 6,
"description": "function score, score mode [multiply]",
"details": [
{
"value": 6,
"description": "function score, product of:",
"details": [
{
"value": 1,
"description": "match filter: *:*"
},
{
"value": 6,
"description": "field value function: (doc['rating'].value * factor=1.0)",
"details": [
{
"value": 1,
"description": "ConstantScore(*:*), product of:",
"details": [
{
"value": 1,
"description": "boost"
},
{
"value": 1,
"description": "queryNorm"
}
]
}
]
}`
]
}
]
},
{
"value": 3.4028235e+38,
"description": "maxBoost"
}
]
},
{
"value": 1,
"description": "queryBoost"
}
]
}
}
]
}
}
你觉得我们应该在得分计算中考虑产品的时间要素。可能新的产品比起那些较老的产品应该赋更高的权重,然后把这些与上述的热度要素进行融合。我们这样写:
POST /ecomercedata/gadgets/_search
{
"query": {
"function_score": {
"query": {
"match_all": {}
},
"functions": [
{
"field_value_factor": {
"field": "rating"
}
},
{
"field_value_factor": {
"field": "dateOfRelease",
}
}
],
"boost_mode": "replace",
"score_mode" : "multiply"
}
}
这样改得分值涨到了一个较高的分值,有多种避免这种结果的方式,我们在赋权重的时候应该注意控制权重。也可以使用定制的脚本来计算得分值,下篇博客我们继续讨论。
es 操作数据源
此数据源来源于 es kibana 6.7.1
自带的数据源 kibana_sample_data_flights
中的100条数据。
减少数据数量便于查看操作是否正确。
数据说明
- 数据源索引名称是
s_flights
- 类型名称是
_doc
(6.7.1以及以后弃用type) - 主分片3个,每个主分片的副分片1个
- 副分片自动在1到2个之间扩展
- 总共有100条数据
- 有10条数据的
_id
是1到10,其余90条是自动生成的uuid
构建
https://www.elastic.co/guide/cn/elasticsearch/guide/current/_add-an-index.html
PUT /s_flights
{
"settings": {
"number_of_shards": 3,
"number_of_replicas": 1,
"auto_expand_replicas": "1-2"
},
"mappings": {
"_doc": {
"properties": {
"AvgTicketPrice": {
"type": "float"
},
"Cancelled": {
"type": "boolean"
},
"Carrier": {
"type": "keyword"
},
"Dest": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"DestAirportID": {
"type": "keyword"
},
"DestCityName": {
"type": "keyword"
},
"DestCountry": {
"type": "keyword"
},
"DestLocation": {
"type": "geo_point"
},
"DestRegion": {
"type": "keyword"
},
"DestWeather": {
"type": "keyword"
},
"DistanceKilometers": {
"type": "float"
},
"DistanceMiles": {
"type": "float"
},
"FlightDelay": {
"type": "boolean"
},
"FlightDelayMin": {
"type": "integer"
},
"FlightDelayType": {
"type": "keyword"
},
"FlightNum": {
"type": "keyword"
},
"FlightTimeHour": {
"type": "float"
},
"FlightTimeMin": {
"type": "float"
},
"Origin": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"OriginAirportID": {
"type": "keyword"
},
"OriginCityName": {
"type": "keyword"
},
"OriginCountry": {
"type": "keyword"
},
"OriginLocation": {
"type": "geo_point"
},
"OriginRegion": {
"type": "keyword"
},
"OriginWeather": {
"type": "keyword"
},
"dayOfWeek": {
"type": "integer"
},
"timestamp": {
"type": "date"
}
}
}
}
}
把 字段 origin、dest 设置为 text 类型,同时也能当做keyword类型, 用于分词测试,官方示例中的mapping中的是keyword
验证
GET /s_flights
清空数据
DELETE /s_flights
数据说明
添加示例数据的位置:http://localhost:5601/app/kibana#/home/tutorial_directory/sampleData
GET /s_flights/_doc/1/_source
航班信息(注释后面是mapping的类型):
{
"FlightNum" : "EN9FHUD", //航班编号 keyword
"DestCountry" : "CA", //目的地国家名 keyword
"OriginWeather" : "Rain",//出发地天气 keyword
"OriginCityName" : "Detroit", // 出发地城市名 keyword
"AvgTicketPrice" : 798.6925673856011, // 平均机票价格 float
"DistanceMiles" : 1586.2909176475928,//出发地到目的地的英里数 float
"FlightDelay" : true, //航班是否延迟 boolean
"DestWeather" : "Rain", //目的地天气 keyword
"Dest" : "Edmonton International Airport",//目的地机场 text
"FlightDelayType" : "Security Delay", // 航班延迟类型 keyword
"OriginCountry" : "US", //出发地国家名 keyword
"dayOfWeek" : 6, //星期 integer
"DistanceKilometers" : 2552.8877705706477, //出发地到目的地的公里数 float
"timestamp" : "2019-04-28T06:25:17", //时间戳 date
"DestLocation" : {//目的地坐标 geo_point
"lat" : "53.30970001", //纬度
"lon" : "-113.5800018" //经度
},
"DestAirportID" : "CYEG", //目的地机场ID keyword
"Carrier" : "Kibana Airlines", //航空公司名 keyword
"Cancelled" : false, //是否取消航班 boolean
"FlightTimeMin" : 451.3759823515883, //航班飞行最小分钟数 float
"Origin" : "Detroit Metropolitan Wayne County Airport",//出发地机场 text
"OriginLocation" : {//出发地坐标 geo_point
"lat" : "42.21239853",//纬度
"lon" : "-83.35340118"//经度
},
"DestRegion" : "CA-AB",//目的地区域 keyword
"OriginAirportID" : "DTW", //出发地的机场ID keyword
"OriginRegion" : "US-MI", //出发地区域 keyword
"DestCityName" : "Edmonton", //目的地城市名称 keyword
"FlightTimeHour" : 7.522933039193138, //航班飞行小时数 keyword
"FlightDelayMin" : 255 //航班延迟最小分钟数 integer
}
{
"category" : [
"Women's Clothing",
"Women's Shoes"
],
"currency" : "EUR",
"customer_first_name" : "Rabbia Al",
"customer_full_name" : "Rabbia Al Simmons",
"customer_gender" : "FEMALE",
"customer_id" : 5,
"customer_last_name" : "Simmons",
"customer_phone" : "",
"day_of_week" : "Friday",
"day_of_week_i" : 4,
"email" : "rabbia al@simmons-family.zzz",
"manufacturer" : [
"Spherecords",
"Angeldale"
],
"order_date" : "2019-04-19T03:56:10+00:00",
"order_id" : 551965,
"products" : [
{
"base_price" : 21.99,
"discount_percentage" : 0,
"quantity" : 1,
"manufacturer" : "Spherecords",
"tax_amount" : 0,
"product_id" : 12893,
"category" : "Women's Clothing",
"sku" : "ZO0636106361",
"taxless_price" : 21.99,
"unit_discount_amount" : 0,
"min_price" : 11.43,
"_id" : "sold_product_551965_12893",
"discount_amount" : 0,
"created_on" : "2016-12-02T03:56:10+00:00",
"product_name" : "Shift dress - black",
"price" : 21.99,
"taxful_price" : 21.99,
"base_unit_price" : 21.99
},
{
"base_price" : 99.99,
"discount_percentage" : 0,
"quantity" : 1,
"manufacturer" : "Angeldale",
"tax_amount" : 0,
"product_id" : 22707,
"category" : "Women's Shoes",
"sku" : "ZO0678706787",
"taxless_price" : 99.99,
"unit_discount_amount" : 0,
"min_price" : 50.99,
"_id" : "sold_product_551965_22707",
"discount_amount" : 0,
"created_on" : "2016-12-02T03:56:10+00:00",
"product_name" : "Cowboy/Biker boots - black",
"price" : 99.99,
"taxful_price" : 99.99,
"base_unit_price" : 99.99
}
],
"sku" : [
"ZO0636106361",
"ZO0678706787"
],
"taxful_total_price" : 121.98,
"taxless_total_price" : 121.98,
"total_quantity" : 2,
"total_unique_products" : 2,
"type" : "order",
"user" : "rabbia",
"geoip" : {
"country_iso_code" : "AE",
"location" : {
"lon" : 55.3,
"lat" : 25.3
},
"region_name" : "Dubai",
"continent_name" : "Asia",
"city_name" : "Dubai"
}
}
{
"referer" : "http://twitter.com/warning/james-wetherbee",
"clientip" : "105.32.126.44",
"response" : "200",
"tags" : [
"success",
"info"
],
"message" : """105.32.126.44 - - [2018-07-22T07:13:13.286Z] "GET /beats/metricbeat HTTP/1.1" 200 8261 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"""",
"request" : "/beats/metricbeat",
"geo" : {
"srcdest" : "EG:EG",
"src" : "EG",
"dest" : "EG",
"coordinates" : {
"lat" : 36.37920333,
"lon" : -97.79111222
}
},
"phpmemory" : null,
"extension" : "",
"index" : "kibana_sample_data_logs",
"url" : "https://www.elastic.co/downloads/beats/metricbeat",
"memory" : null,
"host" : "www.elastic.co",
"utc_time" : "2018-07-22T07:13:13.286Z",
"machine" : {
"ram" : 11811160064,
"os" : "osx"
},
"agent" : "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)",
"ip" : "105.32.126.44",
"bytes" : 8261,
"timestamp" : "2019-04-21T07:13:13.286Z"
}
数据
通过kibana dev tools 执行即可
POST _bulk
{"index":{"_index":"s_flights","_type":"_doc","_id":"1"}}
{"FlightNum":"EN9FHUD","DestCountry":"CA","OriginWeather":"Rain","OriginCityName":"Detroit","AvgTicketPrice":798.6925673856011,"DistanceMiles":1586.2909176475928,"FlightDelay":true,"DestWeather":"Rain","Dest":"Edmonton International Airport","FlightDelayType":"Security Delay","OriginCountry":"US","dayOfWeek":6,"DistanceKilometers":2552.8877705706477,"timestamp":"2019-04-28T06:25:17","DestLocation":{"lat":"53.30970001","lon":"-113.5800018"},"DestAirportID":"CYEG","Carrier":"Kibana Airlines","Cancelled":false,"FlightTimeMin":451.3759823515883,"Origin":"Detroit Metropolitan Wayne County Airport","OriginLocation":{"lat":"42.21239853","lon":"-83.35340118"},"DestRegion":"CA-AB","OriginAirportID":"DTW","OriginRegion":"US-MI","DestCityName":"Edmonton","FlightTimeHour":7.522933039193138,"FlightDelayMin":255}
{"index":{"_index":"s_flights","_type":"_doc","_id":"2"}}
{"FlightNum":"6DJ0DZM","DestCountry":"CN","OriginWeather":"Clear","OriginCityName":"Jebel Ali","AvgTicketPrice":999.8522550241241,"DistanceMiles":4007.258387473065,"FlightDelay":false,"DestWeather":"Sunny","Dest":"Shanghai Hongqiao International Airport","FlightDelayType":"No Delay","OriginCountry":"AE","dayOfWeek":6,"DistanceKilometers":6449.0572423294525,"timestamp":"2019-04-28T12:45:44","DestLocation":{"lat":"31.19790077","lon":"121.3359985"},"DestAirportID":"SHA","Carrier":"Logstash Airways","Cancelled":false,"FlightTimeMin":429.93714948863015,"Origin":"Al Maktoum International Airport","OriginLocation":{"lat":"24.896356","lon":"55.161389"},"DestRegion":"SE-BD","OriginAirportID":"DWC","OriginRegion":"SE-BD","DestCityName":"Shanghai","FlightTimeHour":7.165619158143836,"FlightDelayMin":0}
{"index":{"_index":"s_flights","_type":"_doc","_id":"3"}}
{"FlightNum":"3IWAHPR","DestCountry":"AT","OriginWeather":"Rain","OriginCityName":"Venice","AvgTicketPrice":769.1889854977715,"DistanceMiles":268.99172653633303,"FlightDelay":true,"DestWeather":"Sunny","Dest":"Vienna International Airport","FlightDelayType":"NAS Delay","OriginCountry":"IT","dayOfWeek":6,"DistanceKilometers":432.90022115088834,"timestamp":"2019-04-28T23:26:35","DestLocation":{"lat":"48.11029816","lon":"16.56970024"},"DestAirportID":"VIE","Carrier":"ES-Air","Cancelled":false,"FlightTimeMin":108.3000170116068,"Origin":"Venice Marco Polo Airport","OriginLocation":{"lat":"45.505299","lon":"12.3519"},"DestRegion":"AT-9","OriginAirportID":"VE05","OriginRegion":"IT-34","DestCityName":"Vienna","FlightTimeHour":1.80500028352678,"FlightDelayMin":75}
{"index":{"_index":"s_flights","_type":"_doc","_id":"4"}}
{"FlightNum":"ILXJVIF","DestCountry":"IN","OriginWeather":"Thunder & Lightning","OriginCityName":"Amsterdam","AvgTicketPrice":833.9330143366058,"DistanceMiles":4783.410434491336,"FlightDelay":false,"DestWeather":"Heavy Fog","Dest":"Kempegowda International Airport","FlightDelayType":"No Delay","OriginCountry":"NL","dayOfWeek":6,"DistanceKilometers":7698.152882286025,"timestamp":"2019-04-28T15:45:05","DestLocation":{"lat":"13.1979","lon":"77.706299"},"DestAirportID":"BLR","Carrier":"ES-Air","Cancelled":false,"FlightTimeMin":641.5127401905021,"Origin":"Amsterdam Airport Schiphol","OriginLocation":{"lat":"52.30860138","lon":"4.76388979"},"DestRegion":"SE-BD","OriginAirportID":"AMS","OriginRegion":"NL-NH","DestCityName":"Bangalore","FlightTimeHour":10.691879003175035,"FlightDelayMin":0}
{"index":{"_index":"s_flights","_type":"_doc","_id":"5"}}
{"FlightNum":"C332TSV","DestCountry":"US","OriginWeather":"Cloudy","OriginCityName":"Richmond","AvgTicketPrice":454.55677963525864,"DistanceMiles":1031.24921254256,"FlightDelay":false,"DestWeather":"Rain","Dest":"Tulsa International Airport","FlightDelayType":"No Delay","OriginCountry":"US","dayOfWeek":6,"DistanceKilometers":1659.6347327100937,"timestamp":"2019-04-28T02:39:34","DestLocation":{"lat":"36.19839859","lon":"-95.88809967"},"DestAirportID":"TUL","Carrier":"ES-Air","Cancelled":false,"FlightTimeMin":92.2019295950052,"Origin":"Richmond International Airport","OriginLocation":{"lat":"37.50519943","lon":"-77.31970215"},"DestRegion":"US-OK","OriginAirportID":"RIC","OriginRegion":"US-VA","DestCityName":"Tulsa","FlightTimeHour":1.53669882658342,"FlightDelayMin":0}
{"index":{"_index":"s_flights","_type":"_doc","_id":"6"}}
{"FlightNum":"ORLZ2AC","DestCountry":"CA","OriginWeather":"Clear","OriginCityName":"Wichita","AvgTicketPrice":739.2156145464082,"DistanceMiles":846.484559201929,"FlightDelay":false,"DestWeather":"Hail","Dest":"Winnipeg / James Armstrong Richardson International Airport","FlightDelayType":"No Delay","OriginCountry":"US","dayOfWeek":6,"DistanceKilometers":1362.2848464442693,"timestamp":"2019-04-28T13:27:50","DestLocation":{"lat":"49.90999985","lon":"-97.23989868"},"DestAirportID":"YWG","Carrier":"ES-Air","Cancelled":false,"FlightTimeMin":97.30606046030495,"Origin":"Wichita Mid Continent Airport","OriginLocation":{"lat":"37.64989853","lon":"-97.43309784"},"DestRegion":"CA-MB","OriginAirportID":"ICT","OriginRegion":"US-KS","DestCityName":"Winnipeg","FlightTimeHour":1.6217676743384157,"FlightDelayMin":0}
{"index":{"_index":"s_flights","_type":"_doc","_id":"7"}}
{"FlightNum":"0CRNEKY","DestCountry":"DE","OriginWeather":"Sunny","OriginCityName":"Tokoname","AvgTicketPrice":1190.3077360501295,"DistanceMiles":5779.230637062914,"FlightDelay":false,"DestWeather":"Thunder & Lightning","Dest":"Munich Airport","FlightDelayType":"No Delay","OriginCountry":"JP","dayOfWeek":6,"DistanceKilometers":9300.770150373379,"timestamp":"2019-04-28T17:34:53","DestLocation":{"lat":"48.353802","lon":"11.7861"},"DestAirportID":"MUC","Carrier":"JetBeats","Cancelled":false,"FlightTimeMin":775.0641791977815,"Origin":"Chubu Centrair International Airport","OriginLocation":{"lat":"34.85839844","lon":"136.8049927"},"DestRegion":"DE-BY","OriginAirportID":"NGO","OriginRegion":"SE-BD","DestCityName":"Munich","FlightTimeHour":12.917736319963025,"FlightDelayMin":0}
{"index":{"_index":"s_flights","_type":"_doc","_id":"8"}}
{"FlightNum":"A3XSRL0","DestCountry":"EC","OriginWeather":"Rain","OriginCityName":"Palermo","AvgTicketPrice":632.164184707771,"DistanceMiles":6305.730538787015,"FlightDelay":false,"DestWeather":"Cloudy","Dest":"Mariscal Sucre International Airport","FlightDelayType":"No Delay","OriginCountry":"IT","dayOfWeek":6,"DistanceKilometers":10148.08960821365,"timestamp":"2019-04-28T17:34:53","DestLocation":{"lat":"-0.129166667","lon":"-78.3575"},"DestAirportID":"UIO","Carrier":"ES-Air","Cancelled":false,"FlightTimeMin":922.5536007466955,"Origin":"Falcone Borsellino Airport","OriginLocation":{"lat":"38.175999","lon":"13.091"},"DestRegion":"EC-P","OriginAirportID":"PA03","OriginRegion":"IT-82","DestCityName":"Quito","FlightTimeHour":15.375893345778257,"FlightDelayMin":0}
{"index":{"_index":"s_flights","_type":"_doc","_id":"9"}}
{"FlightNum":"WTIIW8T","DestCountry":"US","OriginWeather":"Rain","OriginCityName":"Quito","AvgTicketPrice":801.3266176769334,"DistanceMiles":3229.7240812074483,"FlightDelay":false,"DestWeather":"Sunny","Dest":"Minneapolis-St Paul International/Wold-Chamberlain Airport","FlightDelayType":"No Delay","OriginCountry":"EC","dayOfWeek":6,"DistanceKilometers":5197.73707174672,"timestamp":"2019-04-28T04:54:42","DestLocation":{"lat":"44.88199997","lon":"-93.22180176"},"DestAirportID":"MSP","Carrier":"ES-Air","Cancelled":false,"FlightTimeMin":371.2669336961943,"Origin":"Mariscal Sucre International Airport","OriginLocation":{"lat":"-0.129166667","lon":"-78.3575"},"DestRegion":"US-MN","OriginAirportID":"UIO","OriginRegion":"SE-BD","DestCityName":"Minneapolis","FlightTimeHour":6.1877822282699055,"FlightDelayMin":0}
{"index":{"_index":"s_flights","_type":"_doc","_id":"10"}}
{"FlightNum":"30G120M","DestCountry":"CH","OriginWeather":"Sunny","OriginCityName":"Sydney","AvgTicketPrice":818.6454280991504,"DistanceMiles":10293.208757785453,"FlightDelay":false,"DestWeather":"Cloudy","Dest":"Zurich Airport","FlightDelayType":"No Delay","OriginCountry":"AU","dayOfWeek":6,"DistanceKilometers":16565.31375508947,"timestamp":"2019-04-28T00:05:24","DestLocation":{"lat":"47.464699","lon":"8.54917"},"DestAirportID":"ZRH","Carrier":"Logstash Airways","Cancelled":false,"FlightTimeMin":871.8586186889196,"Origin":"Sydney Kingsford Smith International Airport","OriginLocation":{"lat":"-33.94609833","lon":"151.177002"},"DestRegion":"CH-ZH","OriginAirportID":"SYD","OriginRegion":"SE-BD","DestCityName":"Zurich","FlightTimeHour":14.53097697814866,"FlightDelayMin":0}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"W46XPNS","DestCountry":"IE","OriginWeather":"Rain","OriginCityName":"Jebel Ali","AvgTicketPrice":552.1357296715516,"DistanceMiles":3692.6657462059065,"FlightDelay":false,"DestWeather":"Clear","Dest":"Dublin Airport","FlightDelayType":"No Delay","OriginCountry":"AE","dayOfWeek":6,"DistanceKilometers":5942.769462661999,"timestamp":"2019-04-28T16:43:22","DestLocation":{"lat":"53.42129898","lon":"-6.270070076"},"DestAirportID":"DUB","Carrier":"Logstash Airways","Cancelled":false,"FlightTimeMin":330.1538590367777,"Origin":"Al Maktoum International Airport","OriginLocation":{"lat":"24.896356","lon":"55.161389"},"DestRegion":"IE-D","OriginAirportID":"DWC","OriginRegion":"SE-BD","DestCityName":"Dublin","FlightTimeHour":5.502564317279629,"FlightDelayMin":0}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"XJOO6AZ","DestCountry":"IT","OriginWeather":"Clear","OriginCityName":"Buenos Aires","AvgTicketPrice":1124.7779208635197,"DistanceMiles":6887.228308599175,"FlightDelay":false,"DestWeather":"Clear","Dest":"Turin Airport","FlightDelayType":"No Delay","OriginCountry":"AR","dayOfWeek":6,"DistanceKilometers":11083.919555074232,"timestamp":"2019-04-28T18:28:36","DestLocation":{"lat":"45.200802","lon":"7.64963"},"DestAirportID":"TO11","Carrier":"Kibana Airlines","Cancelled":false,"FlightTimeMin":554.1959777537115,"Origin":"Ministro Pistarini International Airport","OriginLocation":{"lat":"-34.8222","lon":"-58.5358"},"DestRegion":"IT-21","OriginAirportID":"EZE","OriginRegion":"AR-B","DestCityName":"Torino","FlightTimeHour":9.236599629228525,"FlightDelayMin":0}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"W5W7GTR","DestCountry":"ES","OriginWeather":"Heavy Fog","OriginCityName":"Barcelona","AvgTicketPrice":256.53934500123256,"DistanceMiles":0,"FlightDelay":false,"DestWeather":"Sunny","Dest":"Barcelona International Airport","FlightDelayType":"No Delay","OriginCountry":"ES","dayOfWeek":6,"DistanceKilometers":0,"timestamp":"2019-04-28T14:48:41","DestLocation":{"lat":"41.29710007","lon":"2.078459978"},"DestAirportID":"BCN","Carrier":"ES-Air","Cancelled":false,"FlightTimeMin":0,"Origin":"Barcelona International Airport","OriginLocation":{"lat":"41.29710007","lon":"2.078459978"},"DestRegion":"ES-CT","OriginAirportID":"BCN","OriginRegion":"ES-CT","DestCityName":"Barcelona","FlightTimeHour":0,"FlightDelayMin":0}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"RZGD27G","DestCountry":"PL","OriginWeather":"Damaging Wind","OriginCityName":"Tokyo","AvgTicketPrice":821.5317896862564,"DistanceMiles":5358.819441490414,"FlightDelay":false,"DestWeather":"Rain","Dest":"Warsaw Chopin Airport","FlightDelayType":"No Delay","OriginCountry":"JP","dayOfWeek":6,"DistanceKilometers":8624.183915245949,"timestamp":"2019-04-28T02:53:59","DestLocation":{"lat":"52.16569901","lon":"20.96710014"},"DestAirportID":"WAW","Carrier":"ES-Air","Cancelled":false,"FlightTimeMin":574.94559434973,"Origin":"Tokyo Haneda International Airport","OriginLocation":{"lat":"35.552299","lon":"139.779999"},"DestRegion":"PL-MZ","OriginAirportID":"HND","OriginRegion":"SE-BD","DestCityName":"Warsaw","FlightTimeHour":9.5824265724955,"FlightDelayMin":0}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"K29GWY6","DestCountry":"RU","OriginWeather":"Cloudy","OriginCityName":"Syracuse","AvgTicketPrice":669.8655726244879,"DistanceMiles":5774.020251542041,"FlightDelay":true,"DestWeather":"Rain","Dest":"Ukrainka Air Base","FlightDelayType":"Late Aircraft Delay","OriginCountry":"US","dayOfWeek":6,"DistanceKilometers":9292.384847697675,"timestamp":"2019-04-28T02:53:59","DestLocation":{"lat":"51.169997","lon":"128.445007"},"DestAirportID":"XHBU","Carrier":"ES-Air","Cancelled":false,"FlightTimeMin":799.492323179845,"Origin":"Syracuse Hancock International Airport","OriginLocation":{"lat":"43.11119843","lon":"-76.10630035"},"DestRegion":"RU-AMU","OriginAirportID":"SYR","OriginRegion":"US-NY","DestCityName":"Belogorsk","FlightTimeHour":13.324872052997417,"FlightDelayMin":180}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"B61Q3FI","DestCountry":"IT","OriginWeather":"Hail","OriginCityName":"Barcelona","AvgTicketPrice":1158.2692945811798,"DistanceMiles":764.200884554455,"FlightDelay":false,"DestWeather":"Clear","Dest":"Bari Karol Wojty__a Airport","FlightDelayType":"No Delay","OriginCountry":"ES","dayOfWeek":6,"DistanceKilometers":1229.862108352405,"timestamp":"2019-04-28T10:25:55","DestLocation":{"lat":"41.138901","lon":"16.760599"},"DestAirportID":"BA02","Carrier":"Kibana Airlines","Cancelled":false,"FlightTimeMin":102.48850902936708,"Origin":"Barcelona International Airport","OriginLocation":{"lat":"41.29710007","lon":"2.078459978"},"DestRegion":"IT-75","OriginAirportID":"BCN","OriginRegion":"ES-CT","DestCityName":"Bari","FlightTimeHour":1.708141817156118,"FlightDelayMin":0}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"U2VC5VI","DestCountry":"PL","OriginWeather":"Cloudy","OriginCityName":"Vienna","AvgTicketPrice":844.158140099315,"DistanceMiles":341.50713078020397,"FlightDelay":true,"DestWeather":"Thunder & Lightning","Dest":"Warsaw Chopin Airport","FlightDelayType":"Late Aircraft Delay","OriginCountry":"AT","dayOfWeek":6,"DistanceKilometers":549.6024518783366,"timestamp":"2019-04-28T18:09:04","DestLocation":{"lat":"52.16569901","lon":"20.96710014"},"DestAirportID":"WAW","Carrier":"ES-Air","Cancelled":false,"FlightTimeMin":312.4801225939168,"Origin":"Vienna International Airport","OriginLocation":{"lat":"48.11029816","lon":"16.56970024"},"DestRegion":"PL-MZ","OriginAirportID":"VIE","OriginRegion":"AT-9","DestCityName":"Warsaw","FlightTimeHour":5.2080020432319465,"FlightDelayMin":285}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"JM6V31D","DestCountry":"IT","OriginWeather":"Damaging Wind","OriginCityName":"Oslo","AvgTicketPrice":1014.4973598173747,"DistanceMiles":1141.8277137889752,"FlightDelay":false,"DestWeather":"Cloudy","Dest":"Pisa International Airport","FlightDelayType":"No Delay","OriginCountry":"NO","dayOfWeek":6,"DistanceKilometers":1837.5935802200047,"timestamp":"2019-04-28T19:00:05","DestLocation":{"lat":"43.683899","lon":"10.3927"},"DestAirportID":"PI05","Carrier":"Logstash Airways","Cancelled":false,"FlightTimeMin":153.13279835166705,"Origin":"Oslo Gardermoen Airport","OriginLocation":{"lat":"60.19390106","lon":"11.10039997"},"DestRegion":"IT-52","OriginAirportID":"OSL","OriginRegion":"NO-02","DestCityName":"Pisa","FlightTimeHour":2.5522133058611174,"FlightDelayMin":0}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"215JA06","DestCountry":"IT","OriginWeather":"Clear","OriginCityName":"Buenos Aires","AvgTicketPrice":661.3817492189784,"DistanceMiles":6887.228308599175,"FlightDelay":false,"DestWeather":"Rain","Dest":"Turin Airport","FlightDelayType":"No Delay","OriginCountry":"AR","dayOfWeek":6,"DistanceKilometers":11083.919555074232,"timestamp":"2019-04-28T11:11:29","DestLocation":{"lat":"45.200802","lon":"7.64963"},"DestAirportID":"TO11","Carrier":"Kibana Airlines","Cancelled":false,"FlightTimeMin":692.7449721921395,"Origin":"Ministro Pistarini International Airport","OriginLocation":{"lat":"-34.8222","lon":"-58.5358"},"DestRegion":"IT-21","OriginAirportID":"EZE","OriginRegion":"AR-B","DestCityName":"Torino","FlightTimeHour":11.545749536535657,"FlightDelayMin":0}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"Z1I6EDA","DestCountry":"US","OriginWeather":"Thunder & Lightning","OriginCityName":"Torino","AvgTicketPrice":1174.6346969015287,"DistanceMiles":4189.256294906575,"FlightDelay":false,"DestWeather":"Thunder & Lightning","Dest":"Washington Dulles International Airport","FlightDelayType":"No Delay","OriginCountry":"IT","dayOfWeek":6,"DistanceKilometers":6741.954482670128,"timestamp":"2019-04-28T11:11:29","DestLocation":{"lat":"38.94449997","lon":"-77.45580292"},"DestAirportID":"IAD","Carrier":"Kibana Airlines","Cancelled":false,"FlightTimeMin":518.6118832823175,"Origin":"Turin Airport","OriginLocation":{"lat":"45.200802","lon":"7.64963"},"DestRegion":"US-DC","OriginAirportID":"TO11","OriginRegion":"IT-21","DestCityName":"Washington","FlightTimeHour":8.643531388038626,"FlightDelayMin":0}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"PJIXP3C","DestCountry":"AU","OriginWeather":"Sunny","OriginCityName":"Dublin","AvgTicketPrice":848.0170048968614,"DistanceMiles":10693.224336798747,"FlightDelay":true,"DestWeather":"Heavy Fog","Dest":"Sydney Kingsford Smith International Airport","FlightDelayType":"Weather Delay","OriginCountry":"IE","dayOfWeek":6,"DistanceKilometers":17209.076427081043,"timestamp":"2019-04-28T19:20:50","DestLocation":{"lat":"-33.94609833","lon":"151.177002"},"DestAirportID":"SYD","Carrier":"JetBeats","Cancelled":false,"FlightTimeMin":1225.5672766925652,"Origin":"Dublin Airport","OriginLocation":{"lat":"53.42129898","lon":"-6.270070076"},"DestRegion":"SE-BD","OriginAirportID":"DUB","OriginRegion":"IE-D","DestCityName":"Sydney","FlightTimeHour":20.42612127820942,"FlightDelayMin":150}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"H285CAL","DestCountry":"RU","OriginWeather":"Rain","OriginCityName":"Moscow","AvgTicketPrice":410.2919648154943,"DistanceMiles":3483.9201742117098,"FlightDelay":false,"DestWeather":"Sunny","Dest":"Ukrainka Air Base","FlightDelayType":"No Delay","OriginCountry":"RU","dayOfWeek":6,"DistanceKilometers":5606.82602884657,"timestamp":"2019-04-28T01:15:02","DestLocation":{"lat":"51.169997","lon":"128.445007"},"DestAirportID":"XHBU","Carrier":"Kibana Airlines","Cancelled":false,"FlightTimeMin":266.99171565936047,"Origin":"Sheremetyevo International Airport","OriginLocation":{"lat":"55.972599","lon":"37.4146"},"DestRegion":"RU-AMU","OriginAirportID":"SVO","OriginRegion":"RU-MOS","DestCityName":"Belogorsk","FlightTimeHour":4.449861927656007,"FlightDelayMin":0}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"89CXYB0","DestCountry":"AR","OriginWeather":"Damaging Wind","OriginCityName":"Bogota","AvgTicketPrice":1195.7251356038473,"DistanceMiles":2902.3472529489986,"FlightDelay":false,"DestWeather":"Clear","Dest":"Ministro Pistarini International Airport","FlightDelayType":"No Delay","OriginCountry":"CO","dayOfWeek":6,"DistanceKilometers":4670.875137449953,"timestamp":"2019-04-28T23:09:47","DestLocation":{"lat":"-34.8222","lon":"-58.5358"},"DestAirportID":"EZE","Carrier":"Kibana Airlines","Cancelled":false,"FlightTimeMin":424.62501249545033,"Origin":"El Dorado International Airport","OriginLocation":{"lat":"4.70159","lon":"-74.1469"},"DestRegion":"SE-BD","OriginAirportID":"BOG","OriginRegion":"SE-BD","DestCityName":"Buenos Aires","FlightTimeHour":7.077083541590839,"FlightDelayMin":0}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"2X90HPN","DestCountry":"US","OriginWeather":"Cloudy","OriginCityName":"Santiago","AvgTicketPrice":757.1777242580262,"DistanceMiles":5914.254288262683,"FlightDelay":false,"DestWeather":"Clear","Dest":"Reno Tahoe International Airport","FlightDelayType":"No Delay","OriginCountry":"CL","dayOfWeek":6,"DistanceKilometers":9518.06965328982,"timestamp":"2019-04-28T18:54:32","DestLocation":{"lat":"39.49909973","lon":"-119.7679977"},"DestAirportID":"RNO","Carrier":"ES-Air","Cancelled":false,"FlightTimeMin":594.8793533306138,"Origin":"Comodoro Arturo Merino Benitez International Airport","OriginLocation":{"lat":"-33.39300156","lon":"-70.78579712"},"DestRegion":"US-NV","OriginAirportID":"SCL","OriginRegion":"SE-BD","DestCityName":"Reno","FlightTimeHour":9.914655888843562,"FlightDelayMin":0}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"S5AL4YB","DestCountry":"IT","OriginWeather":"Rain","OriginCityName":"Amsterdam","AvgTicketPrice":1087.3759775692831,"DistanceMiles":508.4249440240821,"FlightDelay":false,"DestWeather":"Rain","Dest":"Turin Airport","FlightDelayType":"No Delay","OriginCountry":"NL","dayOfWeek":6,"DistanceKilometers":818.2306331154924,"timestamp":"2019-04-28T13:09:33","DestLocation":{"lat":"45.200802","lon":"7.64963"},"DestAirportID":"TO11","Carrier":"JetBeats","Cancelled":false,"FlightTimeMin":74.3846030104993,"Origin":"Amsterdam Airport Schiphol","OriginLocation":{"lat":"52.30860138","lon":"4.76388979"},"DestRegion":"IT-21","OriginAirportID":"AMS","OriginRegion":"NL-NH","DestCityName":"Torino","FlightTimeHour":1.2397433835083218,"FlightDelayMin":0}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"MDDV670","DestCountry":"RU","OriginWeather":"Sunny","OriginCityName":"Seoul","AvgTicketPrice":839.4812691492772,"DistanceMiles":943.3383615918764,"FlightDelay":false,"DestWeather":"Thunder & Lightning","Dest":"Ukrainka Air Base","FlightDelayType":"No Delay","OriginCountry":"KR","dayOfWeek":6,"DistanceKilometers":1518.1559321977168,"timestamp":"2019-04-28T11:22:42","DestLocation":{"lat":"51.169997","lon":"128.445007"},"DestAirportID":"XHBU","Carrier":"ES-Air","Cancelled":false,"FlightTimeMin":84.34199623320649,"Origin":"Gimpo International Airport","OriginLocation":{"lat":"37.5583","lon":"126.791"},"DestRegion":"RU-AMU","OriginAirportID":"GMP","OriginRegion":"SE-BD","DestCityName":"Belogorsk","FlightTimeHour":1.4056999372201082,"FlightDelayMin":0}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"YWNQWY2","DestCountry":"CA","OriginWeather":"Damaging Wind","OriginCityName":"Verona","AvgTicketPrice":685.3744330082054,"DistanceMiles":4585.376414414682,"FlightDelay":false,"DestWeather":"Cloudy","Dest":"Winnipeg / James Armstrong Richardson International Airport","FlightDelayType":"No Delay","OriginCountry":"IT","dayOfWeek":6,"DistanceKilometers":7379.448020279781,"timestamp":"2019-04-28T02:42:20","DestLocation":{"lat":"49.90999985","lon":"-97.23989868"},"DestAirportID":"YWG","Carrier":"Logstash Airways","Cancelled":false,"FlightTimeMin":491.96320135198545,"Origin":"Verona Villafranca Airport","OriginLocation":{"lat":"45.395699","lon":"10.8885"},"DestRegion":"CA-MB","OriginAirportID":"VR10","OriginRegion":"IT-34","DestCityName":"Winnipeg","FlightTimeHour":8.199386689199757,"FlightDelayMin":0}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"AIEDCBP","DestCountry":"SE","OriginWeather":"Cloudy","OriginCityName":"Ottawa","AvgTicketPrice":516.3969679276287,"DistanceMiles":3724.4863279452634,"FlightDelay":false,"DestWeather":"Cloudy","Dest":"Stockholm-Arlanda Airport","FlightDelayType":"No Delay","OriginCountry":"CA","dayOfWeek":6,"DistanceKilometers":5993.979724960743,"timestamp":"2019-04-28T22:17:04","DestLocation":{"lat":"59.65190125","lon":"17.91860008"},"DestAirportID":"ARN","Carrier":"Kibana Airlines","Cancelled":false,"FlightTimeMin":544.9072477237039,"Origin":"Ottawa Macdonald-Cartier International Airport","OriginLocation":{"lat":"45.32249832","lon":"-75.66919708"},"DestRegion":"SE-AB","OriginAirportID":"YOW","OriginRegion":"CA-ON","DestCityName":"Stockholm","FlightTimeHour":9.081787462061731,"FlightDelayMin":0}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"IK2LIK5","DestCountry":"US","OriginWeather":"Clear","OriginCityName":"Melbourne","AvgTicketPrice":782.1572154174901,"DistanceMiles":9506.777747492553,"FlightDelay":true,"DestWeather":"Heavy Fog","Dest":"Scott AFB/Midamerica Airport","FlightDelayType":"NAS Delay","OriginCountry":"AU","dayOfWeek":6,"DistanceKilometers":15299.675727260657,"timestamp":"2019-04-28T22:19:50","DestLocation":{"lat":"38.5452","lon":"-89.835197"},"DestAirportID":"BLV","Carrier":"ES-Air","Cancelled":false,"FlightTimeMin":1164.9819848478141,"Origin":"Melbourne International Airport","OriginLocation":{"lat":"-37.673302","lon":"144.843002"},"DestRegion":"US-IL","OriginAirportID":"MEL","OriginRegion":"SE-BD","DestCityName":"Belleville","FlightTimeHour":19.416366414130234,"FlightDelayMin":315}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"UVR008K","DestCountry":"US","OriginWeather":"Hail","OriginCityName":"Bari","AvgTicketPrice":850.0940911032192,"DistanceMiles":5182.355258719049,"FlightDelay":false,"DestWeather":"Damaging Wind","Dest":"Savannah Hilton Head International Airport","FlightDelayType":"No Delay","OriginCountry":"IT","dayOfWeek":6,"DistanceKilometers":8340.19234148795,"timestamp":"2019-04-28T11:39:06","DestLocation":{"lat":"32.12760162","lon":"-81.20210266"},"DestAirportID":"SAV","Carrier":"ES-Air","Cancelled":false,"FlightTimeMin":490.59954949929113,"Origin":"Bari Karol Wojty__a Airport","OriginLocation":{"lat":"41.138901","lon":"16.760599"},"DestRegion":"US-GA","OriginAirportID":"BA02","OriginRegion":"IT-75","DestCityName":"Savannah","FlightTimeHour":8.176659158321518,"FlightDelayMin":0}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"VMFHGIB","DestCountry":"CA","OriginWeather":"Clear","OriginCityName":"Norfolk","AvgTicketPrice":926.5541281993565,"DistanceMiles":1380.2095204827594,"FlightDelay":true,"DestWeather":"Clear","Dest":"Winnipeg / James Armstrong Richardson International Airport","FlightDelayType":"Security Delay","OriginCountry":"US","dayOfWeek":6,"DistanceKilometers":2221.231910531806,"timestamp":"2019-04-28T15:23:05","DestLocation":{"lat":"49.90999985","lon":"-97.23989868"},"DestAirportID":"YWG","Carrier":"Kibana Airlines","Cancelled":false,"FlightTimeMin":500.8639931178312,"Origin":"Norfolk International Airport","OriginLocation":{"lat":"36.89459991","lon":"-76.20120239"},"DestRegion":"CA-MB","OriginAirportID":"ORF","OriginRegion":"US-VA","DestCityName":"Winnipeg","FlightTimeHour":8.34773321863052,"FlightDelayMin":330}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"8AM2TTH","DestCountry":"CH","OriginWeather":"Cloudy","OriginCityName":"Verona","AvgTicketPrice":883.3712093165132,"DistanceMiles":181.37932096597845,"FlightDelay":true,"DestWeather":"Cloudy","Dest":"Zurich Airport","FlightDelayType":"Carrier Delay","OriginCountry":"IT","dayOfWeek":6,"DistanceKilometers":291.90172192067166,"timestamp":"2019-04-28T18:09:10","DestLocation":{"lat":"47.464699","lon":"8.54917"},"DestAirportID":"ZRH","Carrier":"JetBeats","Cancelled":false,"FlightTimeMin":63.24385762004198,"Origin":"Verona Villafranca Airport","OriginLocation":{"lat":"45.395699","lon":"10.8885"},"DestRegion":"CH-ZH","OriginAirportID":"VR10","OriginRegion":"IT-34","DestCityName":"Zurich","FlightTimeHour":1.0540642936673663,"FlightDelayMin":45}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"XCS3M3E","DestCountry":"CN","OriginWeather":"Sunny","OriginCityName":"Rome","AvgTicketPrice":1068.8582885226288,"DistanceMiles":5673.099672530585,"FlightDelay":false,"DestWeather":"Clear","Dest":"Shanghai Hongqiao International Airport","FlightDelayType":"No Delay","OriginCountry":"IT","dayOfWeek":6,"DistanceKilometers":9129.968919389063,"timestamp":"2019-04-28T18:09:10","DestLocation":{"lat":"31.19790077","lon":"121.3359985"},"DestAirportID":"SHA","Carrier":"JetBeats","Cancelled":false,"FlightTimeMin":507.22049552161457,"Origin":"Ciampino___G. B. Pastine International Airport","OriginLocation":{"lat":"41.7994","lon":"12.5949"},"DestRegion":"SE-BD","OriginAirportID":"RM12","OriginRegion":"IT-62","DestCityName":"Shanghai","FlightTimeHour":8.453674925360243,"FlightDelayMin":0}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"94QR81F","DestCountry":"US","OriginWeather":"Thunder & Lightning","OriginCityName":"Seoul","AvgTicketPrice":931.4822176577402,"DistanceMiles":6538.659951769765,"FlightDelay":false,"DestWeather":"Heavy Fog","Dest":"Kansas City International Airport","FlightDelayType":"No Delay","OriginCountry":"KR","dayOfWeek":6,"DistanceKilometers":10522.95316142096,"timestamp":"2019-04-28T07:16:16","DestLocation":{"lat":"39.2976","lon":"-94.713898"},"DestAirportID":"MCI","Carrier":"Logstash Airways","Cancelled":false,"FlightTimeMin":956.6321055837237,"Origin":"Incheon International Airport","OriginLocation":{"lat":"37.46910095","lon":"126.4509964"},"DestRegion":"US-MO","OriginAirportID":"ICN","OriginRegion":"SE-BD","DestCityName":"Kansas City","FlightTimeHour":15.943868426395396,"FlightDelayMin":0}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"MK8MZN2","DestCountry":"US","OriginWeather":"Hail","OriginCityName":"Dublin","AvgTicketPrice":681.4229913598592,"DistanceMiles":3881.8505743374412,"FlightDelay":false,"DestWeather":"Thunder & Lightning","Dest":"Savannah Hilton Head International Airport","FlightDelayType":"No Delay","OriginCountry":"IE","dayOfWeek":6,"DistanceKilometers":6247.232930706516,"timestamp":"2019-04-28T23:26:08","DestLocation":{"lat":"32.12760162","lon":"-81.20210266"},"DestAirportID":"SAV","Carrier":"JetBeats","Cancelled":true,"FlightTimeMin":446.23092362189396,"Origin":"Dublin Airport","OriginLocation":{"lat":"53.42129898","lon":"-6.270070076"},"DestRegion":"US-GA","OriginAirportID":"DUB","OriginRegion":"IE-D","DestCityName":"Savannah","FlightTimeHour":7.4371820603649,"FlightDelayMin":0}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"RNLXB5A","DestCountry":"US","OriginWeather":"Rain","OriginCityName":"Cologne","AvgTicketPrice":683.4233231563454,"DistanceMiles":5552.056992096554,"FlightDelay":false,"DestWeather":"Cloudy","Dest":"Phoenix Sky Harbor International Airport","FlightDelayType":"No Delay","OriginCountry":"DE","dayOfWeek":6,"DistanceKilometers":8935.169607888636,"timestamp":"2019-04-28T11:15:07","DestLocation":{"lat":"33.43429947","lon":"-112.012001"},"DestAirportID":"PHX","Carrier":"Kibana Airlines","Cancelled":false,"FlightTimeMin":525.5982122287433,"Origin":"Cologne Bonn Airport","OriginLocation":{"lat":"50.86589813","lon":"7.142739773"},"DestRegion":"US-AZ","OriginAirportID":"CGN","OriginRegion":"DE-NW","DestCityName":"Phoenix","FlightTimeHour":8.759970203812388,"FlightDelayMin":0}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"V45CU66","DestCountry":"AT","OriginWeather":"Sunny","OriginCityName":"Oslo","AvgTicketPrice":694.2349201725368,"DistanceMiles":863.997894828143,"FlightDelay":false,"DestWeather":"Cloudy","Dest":"Vienna International Airport","FlightDelayType":"No Delay","OriginCountry":"NO","dayOfWeek":6,"DistanceKilometers":1390.469828054303,"timestamp":"2019-04-28T05:59:00","DestLocation":{"lat":"48.11029816","lon":"16.56970024"},"DestAirportID":"VIE","Carrier":"JetBeats","Cancelled":false,"FlightTimeMin":115.87248567119191,"Origin":"Oslo Gardermoen Airport","OriginLocation":{"lat":"60.19390106","lon":"11.10039997"},"DestRegion":"AT-9","OriginAirportID":"OSL","OriginRegion":"NO-02","DestCityName":"Vienna","FlightTimeHour":1.931208094519865,"FlightDelayMin":0}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"5AJITUD","DestCountry":"RU","OriginWeather":"Clear","OriginCityName":"Olenegorsk","AvgTicketPrice":205.91781365026878,"DistanceMiles":3143.69237782736,"FlightDelay":false,"DestWeather":"Damaging Wind","Dest":"Ukrainka Air Base","FlightDelayType":"No Delay","OriginCountry":"RU","dayOfWeek":6,"DistanceKilometers":5059.282466102195,"timestamp":"2019-04-28T14:30:08","DestLocation":{"lat":"51.169997","lon":"128.445007"},"DestAirportID":"XHBU","Carrier":"Kibana Airlines","Cancelled":false,"FlightTimeMin":361.37731900729966,"Origin":"Olenya Air Base","OriginLocation":{"lat":"68.15180206","lon":"33.46390152"},"DestRegion":"RU-AMU","OriginAirportID":"XLMO","OriginRegion":"RU-MUR","DestCityName":"Belogorsk","FlightTimeHour":6.022955316788328,"FlightDelayMin":0}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"5JQG700","DestCountry":"IT","OriginWeather":"Heavy Fog","OriginCityName":"Treviso","AvgTicketPrice":375.154155838214,"DistanceMiles":65.75376437286016,"FlightDelay":true,"DestWeather":"Heavy Fog","Dest":"Verona Villafranca Airport","FlightDelayType":"NAS Delay","OriginCountry":"IT","dayOfWeek":6,"DistanceKilometers":105.82042617087626,"timestamp":"2019-04-28T21:23:24","DestLocation":{"lat":"45.395699","lon":"10.8885"},"DestAirportID":"VR10","Carrier":"Kibana Airlines","Cancelled":true,"FlightTimeMin":80.03906791289887,"Origin":"Treviso-Sant'Angelo Airport","OriginLocation":{"lat":"45.648399","lon":"12.1944"},"DestRegion":"IT-34","OriginAirportID":"TV01","OriginRegion":"IT-34","DestCityName":"Verona","FlightTimeHour":1.3339844652149813,"FlightDelayMin":75}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"27O68O2","DestCountry":"IT","OriginWeather":"Sunny","OriginCityName":"Manchester","AvgTicketPrice":844.8148973322255,"DistanceMiles":1157.0759753834664,"FlightDelay":false,"DestWeather":"Sunny","Dest":"Naples International Airport","FlightDelayType":"No Delay","OriginCountry":"GB","dayOfWeek":6,"DistanceKilometers":1862.1332785275295,"timestamp":"2019-04-28T18:56:11","DestLocation":{"lat":"40.886002","lon":"14.2908"},"DestAirportID":"NA01","Carrier":"Kibana Airlines","Cancelled":false,"FlightTimeMin":103.45184880708497,"Origin":"Manchester Airport","OriginLocation":{"lat":"53.35369873","lon":"-2.274950027"},"DestRegion":"IT-72","OriginAirportID":"MAN","OriginRegion":"GB-ENG","DestCityName":"Naples","FlightTimeHour":1.7241974801180828,"FlightDelayMin":0}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"R92IA62","DestCountry":"RU","OriginWeather":"Rain","OriginCityName":"Montreal","AvgTicketPrice":531.1744915416451,"DistanceMiles":3758.4852008494863,"FlightDelay":false,"DestWeather":"Heavy Fog","Dest":"Olenya Air Base","FlightDelayType":"No Delay","OriginCountry":"CA","dayOfWeek":6,"DistanceKilometers":6048.695607075916,"timestamp":"2019-04-28T16:01:06","DestLocation":{"lat":"68.15180206","lon":"33.46390152"},"DestAirportID":"XLMO","Carrier":"Kibana Airlines","Cancelled":false,"FlightTimeMin":336.0386448375509,"Origin":"Montreal / Pierre Elliott Trudeau International Airport","OriginLocation":{"lat":"45.47060013","lon":"-73.74079895"},"DestRegion":"RU-MUR","OriginAirportID":"YUL","OriginRegion":"CA-QC","DestCityName":"Olenegorsk","FlightTimeHour":5.600644080625849,"FlightDelayMin":0}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"NA1KQ98","DestCountry":"CA","OriginWeather":"Cloudy","OriginCityName":"Copenhagen","AvgTicketPrice":1181.9821281122495,"DistanceMiles":4329.99513718705,"FlightDelay":false,"DestWeather":"Rain","Dest":"Edmonton International Airport","FlightDelayType":"No Delay","OriginCountry":"DK","dayOfWeek":6,"DistanceKilometers":6968.451694061157,"timestamp":"2019-04-28T04:41:44","DestLocation":{"lat":"53.30970001","lon":"-113.5800018"},"DestAirportID":"CYEG","Carrier":"Kibana Airlines","Cancelled":false,"FlightTimeMin":536.034745697012,"Origin":"Copenhagen Kastrup Airport","OriginLocation":{"lat":"55.61790085","lon":"12.65600014"},"DestRegion":"CA-AB","OriginAirportID":"CPH","OriginRegion":"DK-84","DestCityName":"Edmonton","FlightTimeHour":8.933912428283532,"FlightDelayMin":0}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"5MFTLZ3","DestCountry":"CN","OriginWeather":"Cloudy","OriginCityName":"Xi'an","AvgTicketPrice":282.8937129473871,"DistanceMiles":0,"FlightDelay":true,"DestWeather":"Sunny","Dest":"Xi'an Xianyang International Airport","FlightDelayType":"Carrier Delay","OriginCountry":"CN","dayOfWeek":6,"DistanceKilometers":0,"timestamp":"2019-04-28T04:07:38","DestLocation":{"lat":"34.447102","lon":"108.751999"},"DestAirportID":"XIY","Carrier":"Logstash Airways","Cancelled":false,"FlightTimeMin":45,"Origin":"Xi'an Xianyang International Airport","OriginLocation":{"lat":"34.447102","lon":"108.751999"},"DestRegion":"SE-BD","OriginAirportID":"XIY","OriginRegion":"SE-BD","DestCityName":"Xi'an","FlightTimeHour":0.75,"FlightDelayMin":45}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"X8XNYHK","DestCountry":"AT","OriginWeather":"Sunny","OriginCityName":"Gulfport","AvgTicketPrice":880.9987498063086,"DistanceMiles":5345.6722214880665,"FlightDelay":false,"DestWeather":"Clear","Dest":"Vienna International Airport","FlightDelayType":"No Delay","OriginCountry":"US","dayOfWeek":6,"DistanceKilometers":8603.025515618492,"timestamp":"2019-04-28T17:21:35","DestLocation":{"lat":"48.11029816","lon":"16.56970024"},"DestAirportID":"VIE","Carrier":"Logstash Airways","Cancelled":false,"FlightTimeMin":716.9187929682076,"Origin":"Gulfport Biloxi International Airport","OriginLocation":{"lat":"30.40730095","lon":"-89.07009888"},"DestRegion":"AT-9","OriginAirportID":"GPT","OriginRegion":"US-MS","DestCityName":"Vienna","FlightTimeHour":11.948646549470128,"FlightDelayMin":0}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"VLZ7GBB","DestCountry":"EC","OriginWeather":"Heavy Fog","OriginCityName":"Dubai","AvgTicketPrice":1068.3693224132169,"DistanceMiles":8904.884248324388,"FlightDelay":true,"DestWeather":"Hail","Dest":"Mariscal Sucre International Airport","FlightDelayType":"NAS Delay","OriginCountry":"AE","dayOfWeek":6,"DistanceKilometers":14331.022035735365,"timestamp":"2019-04-28T14:50:45","DestLocation":{"lat":"-0.129166667","lon":"-78.3575"},"DestAirportID":"UIO","Carrier":"Kibana Airlines","Cancelled":false,"FlightTimeMin":1081.167890874187,"Origin":"Dubai International Airport","OriginLocation":{"lat":"25.25279999","lon":"55.36439896"},"DestRegion":"SE-BD","OriginAirportID":"DXB","OriginRegion":"SE-BD","DestCityName":"Quito","FlightTimeHour":18.019464847903116,"FlightDelayMin":285}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"ZS958C0","DestCountry":"US","OriginWeather":"Thunder & Lightning","OriginCityName":"Ottawa","AvgTicketPrice":830.0020286221413,"DistanceMiles":2365.673056688675,"FlightDelay":false,"DestWeather":"Hail","Dest":"San Diego International Airport","FlightDelayType":"No Delay","OriginCountry":"CA","dayOfWeek":6,"DistanceKilometers":3807.1817397435793,"timestamp":"2019-04-28T19:50:19","DestLocation":{"lat":"32.73360062","lon":"-117.1900024"},"DestAirportID":"SAN","Carrier":"Logstash Airways","Cancelled":false,"FlightTimeMin":181.29436855921807,"Origin":"Ottawa Macdonald-Cartier International Airport","OriginLocation":{"lat":"45.32249832","lon":"-75.66919708"},"DestRegion":"US-CA","OriginAirportID":"YOW","OriginRegion":"CA-ON","DestCityName":"San Diego","FlightTimeHour":3.0215728093203014,"FlightDelayMin":0}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"P7UAHH6","DestCountry":"RU","OriginWeather":"Hail","OriginCityName":"Paris","AvgTicketPrice":1111.9401422376345,"DistanceMiles":1695.9928029120558,"FlightDelay":false,"DestWeather":"Heavy Fog","Dest":"Olenya Air Base","FlightDelayType":"No Delay","OriginCountry":"FR","dayOfWeek":6,"DistanceKilometers":2729.4358414096996,"timestamp":"2019-04-28T00:23:52","DestLocation":{"lat":"68.15180206","lon":"33.46390152"},"DestAirportID":"XLMO","Carrier":"Logstash Airways","Cancelled":false,"FlightTimeMin":248.13053103724542,"Origin":"Charles de Gaulle International Airport","OriginLocation":{"lat":"49.01279831","lon":"2.549999952"},"DestRegion":"RU-MUR","OriginAirportID":"CDG","OriginRegion":"FR-J","DestCityName":"Olenegorsk","FlightTimeHour":4.135508850620757,"FlightDelayMin":0}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"TIA56QO","DestCountry":"PL","OriginWeather":"Heavy Fog","OriginCityName":"Frankfurt am Main","AvgTicketPrice":509.2291432400352,"DistanceMiles":558.5532803175381,"FlightDelay":false,"DestWeather":"Cloudy","Dest":"Warsaw Chopin Airport","FlightDelayType":"No Delay","OriginCountry":"DE","dayOfWeek":6,"DistanceKilometers":898.904370359348,"timestamp":"2019-04-28T02:52:44","DestLocation":{"lat":"52.16569901","lon":"20.96710014"},"DestAirportID":"WAW","Carrier":"Kibana Airlines","Cancelled":false,"FlightTimeMin":49.939131686630446,"Origin":"Frankfurt am Main Airport","OriginLocation":{"lat":"50.033333","lon":"8.570556"},"DestRegion":"PL-MZ","OriginAirportID":"FRA","OriginRegion":"DE-HE","DestCityName":"Warsaw","FlightTimeHour":0.8323188614438408,"FlightDelayMin":0}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"KKDVHEG","DestCountry":"ZA","OriginWeather":"Sunny","OriginCityName":"Cagliari","AvgTicketPrice":826.0982881309054,"DistanceMiles":4665.782343328863,"FlightDelay":false,"DestWeather":"Sunny","Dest":"OR Tambo International Airport","FlightDelayType":"No Delay","OriginCountry":"IT","dayOfWeek":6,"DistanceKilometers":7508.848819542246,"timestamp":"2019-04-28T17:13:49","DestLocation":{"lat":"-26.1392","lon":"28.246"},"DestAirportID":"JNB","Carrier":"ES-Air","Cancelled":false,"FlightTimeMin":469.3030512213904,"Origin":"Cagliari Elmas Airport","OriginLocation":{"lat":"39.251499","lon":"9.05428"},"DestRegion":"SE-BD","OriginAirportID":"CA07","OriginRegion":"IT-88","DestCityName":"Johannesburg","FlightTimeHour":7.821717520356506,"FlightDelayMin":0}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"SFKI761","DestCountry":"IT","OriginWeather":"Cloudy","OriginCityName":"New Delhi","AvgTicketPrice":1063.3514109538767,"DistanceMiles":3889.5758923959584,"FlightDelay":false,"DestWeather":"Sunny","Dest":"Turin Airport","FlightDelayType":"No Delay","OriginCountry":"IN","dayOfWeek":6,"DistanceKilometers":6259.665624972082,"timestamp":"2019-04-28T04:24:30","DestLocation":{"lat":"45.200802","lon":"7.64963"},"DestAirportID":"TO11","Carrier":"Logstash Airways","Cancelled":false,"FlightTimeMin":368.2156249983577,"Origin":"Indira Gandhi International Airport","OriginLocation":{"lat":"28.5665","lon":"77.103104"},"DestRegion":"IT-21","OriginAirportID":"DEL","OriginRegion":"SE-BD","DestCityName":"Torino","FlightTimeHour":6.136927083305962,"FlightDelayMin":0}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"WSOZG8W","DestCountry":"CA","OriginWeather":"Clear","OriginCityName":"Erie","AvgTicketPrice":793.5376930130036,"DistanceMiles":979.8240288672278,"FlightDelay":true,"DestWeather":"Rain","Dest":"Winnipeg / James Armstrong Richardson International Airport","FlightDelayType":"Weather Delay","OriginCountry":"US","dayOfWeek":6,"DistanceKilometers":1576.8739219133,"timestamp":"2019-04-28T10:09:23","DestLocation":{"lat":"49.90999985","lon":"-97.23989868"},"DestAirportID":"YWG","Carrier":"ES-Air","Cancelled":false,"FlightTimeMin":476.4061601594417,"Origin":"Erie International Tom Ridge Field","OriginLocation":{"lat":"42.08312701","lon":"-80.17386675"},"DestRegion":"CA-MB","OriginAirportID":"ERI","OriginRegion":"US-PA","DestCityName":"Winnipeg","FlightTimeHour":7.940102669324029,"FlightDelayMin":345}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"VHU61ZH","DestCountry":"CN","OriginWeather":"Clear","OriginCityName":"Washington","AvgTicketPrice":878.7432521860824,"DistanceMiles":7365.320987414931,"FlightDelay":false,"DestWeather":"Clear","Dest":"Xi'an Xianyang International Airport","FlightDelayType":"No Delay","OriginCountry":"US","dayOfWeek":6,"DistanceKilometers":11853.335139170294,"timestamp":"2019-04-28T15:14:40","DestLocation":{"lat":"34.447102","lon":"108.751999"},"DestAirportID":"XIY","Carrier":"JetBeats","Cancelled":false,"FlightTimeMin":987.7779282641912,"Origin":"Washington Dulles International Airport","OriginLocation":{"lat":"38.94449997","lon":"-77.45580292"},"DestRegion":"SE-BD","OriginAirportID":"IAD","OriginRegion":"US-DC","DestCityName":"Xi'an","FlightTimeHour":16.462965471069854,"FlightDelayMin":0}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"5OLTF79","DestCountry":"DK","OriginWeather":"Heavy Fog","OriginCityName":"Bologna","AvgTicketPrice":1146.8315113852943,"DistanceMiles":768.338663154678,"FlightDelay":false,"DestWeather":"Rain","Dest":"Copenhagen Kastrup Airport","FlightDelayType":"No Delay","OriginCountry":"IT","dayOfWeek":6,"DistanceKilometers":1236.5212175160023,"timestamp":"2019-04-28T15:14:40","DestLocation":{"lat":"55.61790085","lon":"12.65600014"},"DestAirportID":"CPH","Carrier":"Logstash Airways","Cancelled":false,"FlightTimeMin":77.28257609475014,"Origin":"Bologna Guglielmo Marconi Airport","OriginLocation":{"lat":"44.5354","lon":"11.2887"},"DestRegion":"DK-84","OriginAirportID":"BO08","OriginRegion":"IT-45","DestCityName":"Copenhagen","FlightTimeHour":1.2880429349125024,"FlightDelayMin":0}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"3ONJ5MH","DestCountry":"US","OriginWeather":"Clear","OriginCityName":"Johannesburg","AvgTicketPrice":1079.4445319435404,"DistanceMiles":8175.917901640706,"FlightDelay":true,"DestWeather":"Cloudy","Dest":"Orlando Sanford International Airport","FlightDelayType":"NAS Delay","OriginCountry":"ZA","dayOfWeek":6,"DistanceKilometers":13157.86441949806,"timestamp":"2019-04-28T00:49:52","DestLocation":{"lat":"28.77759933","lon":"-81.23750305"},"DestAirportID":"SFB","Carrier":"Logstash Airways","Cancelled":false,"FlightTimeMin":1015.9924677498923,"Origin":"OR Tambo International Airport","OriginLocation":{"lat":"-26.1392","lon":"28.246"},"DestRegion":"US-FL","OriginAirportID":"JNB","OriginRegion":"SE-BD","DestCityName":"Orlando","FlightTimeHour":16.93320779583154,"FlightDelayMin":285}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"UQUMKQW","DestCountry":"FR","OriginWeather":"Cloudy","OriginCityName":"Madrid","AvgTicketPrice":997.1197469390574,"DistanceMiles":661.5107090848768,"FlightDelay":false,"DestWeather":"Clear","Dest":"Charles de Gaulle International Airport","FlightDelayType":"No Delay","OriginCountry":"ES","dayOfWeek":6,"DistanceKilometers":1064.598290601492,"timestamp":"2019-04-28T22:40:30","DestLocation":{"lat":"49.01279831","lon":"2.549999952"},"DestAirportID":"CDG","Carrier":"Logstash Airways","Cancelled":false,"FlightTimeMin":70.9732193734328,"Origin":"Adolfo Suarez Madrid— Barajas Airport","OriginLocation":{"lat":"40.471926","lon":"-3.56264"},"DestRegion":"FR-J","OriginAirportID":"MAD","OriginRegion":"ES-M","DestCityName":"Paris","FlightTimeHour":1.1828869895572134,"FlightDelayMin":0}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"319HBJ7","DestCountry":"CN","OriginWeather":"Heavy Fog","OriginCityName":"Munich","AvgTicketPrice":695.3876862293589,"DistanceMiles":5466.653686896351,"FlightDelay":false,"DestWeather":"Sunny","Dest":"Shanghai Pudong International Airport","FlightDelayType":"No Delay","OriginCountry":"DE","dayOfWeek":6,"DistanceKilometers":8797.726311084522,"timestamp":"2019-04-28T13:50:33","DestLocation":{"lat":"31.14340019","lon":"121.8050003"},"DestAirportID":"PVG","Carrier":"ES-Air","Cancelled":false,"FlightTimeMin":676.7481777757324,"Origin":"Munich Airport","OriginLocation":{"lat":"48.353802","lon":"11.7861"},"DestRegion":"SE-BD","OriginAirportID":"MUC","OriginRegion":"DE-BY","DestCityName":"Shanghai","FlightTimeHour":11.279136296262207,"FlightDelayMin":0}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"R2ZVPM3","DestCountry":"CH","OriginWeather":"Heavy Fog","OriginCityName":"Belogorsk","AvgTicketPrice":911.4413566645949,"DistanceMiles":4763.092180980121,"FlightDelay":false,"DestWeather":"Clear","Dest":"Zurich Airport","FlightDelayType":"No Delay","OriginCountry":"RU","dayOfWeek":6,"DistanceKilometers":7665.453822907272,"timestamp":"2019-04-28T15:26:50","DestLocation":{"lat":"47.464699","lon":"8.54917"},"DestAirportID":"ZRH","Carrier":"ES-Air","Cancelled":false,"FlightTimeMin":403.4449380477512,"Origin":"Ukrainka Air Base","OriginLocation":{"lat":"51.169997","lon":"128.445007"},"DestRegion":"CH-ZH","OriginAirportID":"XHBU","OriginRegion":"RU-AMU","DestCityName":"Zurich","FlightTimeHour":6.724082300795853,"FlightDelayMin":0}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"ULIKE0R","DestCountry":"CH","OriginWeather":"Heavy Fog","OriginCityName":"London","AvgTicketPrice":818.8628669911516,"DistanceMiles":469.3646254904239,"FlightDelay":false,"DestWeather":"Sunny","Dest":"Zurich Airport","FlightDelayType":"No Delay","OriginCountry":"GB","dayOfWeek":6,"DistanceKilometers":755.3691438452609,"timestamp":"2019-04-28T14:57:30","DestLocation":{"lat":"47.464699","lon":"8.54917"},"DestAirportID":"ZRH","Carrier":"Logstash Airways","Cancelled":false,"FlightTimeMin":44.43347904972123,"Origin":"London Gatwick Airport","OriginLocation":{"lat":"51.14810181","lon":"-0.190277994"},"DestRegion":"CH-ZH","OriginAirportID":"LGW","OriginRegion":"GB-ENG","DestCityName":"Zurich","FlightTimeHour":0.7405579841620205,"FlightDelayMin":0}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"LZOH5ZJ","DestCountry":"IN","OriginWeather":"Rain","OriginCityName":"Johannesburg","AvgTicketPrice":965.1848993442622,"DistanceMiles":4502.079993979012,"FlightDelay":true,"DestWeather":"Hail","Dest":"Rajiv Gandhi International Airport","FlightDelayType":"NAS Delay","OriginCountry":"ZA","dayOfWeek":6,"DistanceKilometers":7245.39542583016,"timestamp":"2019-04-28T14:57:30","DestLocation":{"lat":"17.23131752","lon":"78.42985535"},"DestAirportID":"HYD","Carrier":"ES-Air","Cancelled":false,"FlightTimeMin":737.837214114385,"Origin":"OR Tambo International Airport","OriginLocation":{"lat":"-26.1392","lon":"28.246"},"DestRegion":"SE-BD","OriginAirportID":"JNB","OriginRegion":"SE-BD","DestCityName":"Hyderabad","FlightTimeHour":12.297286901906416,"FlightDelayMin":285}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"M3JJHF2","DestCountry":"DE","OriginWeather":"Sunny","OriginCityName":"Adelaide","AvgTicketPrice":985.9280069646895,"DistanceMiles":9595.200739522528,"FlightDelay":false,"DestWeather":"Cloudy","Dest":"Munich Airport","FlightDelayType":"No Delay","OriginCountry":"AU","dayOfWeek":6,"DistanceKilometers":15441.978738946143,"timestamp":"2019-04-28T02:08:51","DestLocation":{"lat":"48.353802","lon":"11.7861"},"DestAirportID":"MUC","Carrier":"JetBeats","Cancelled":false,"FlightTimeMin":772.0989369473072,"Origin":"Adelaide International Airport","OriginLocation":{"lat":"-34.945","lon":"138.531006"},"DestRegion":"DE-BY","OriginAirportID":"ADL","OriginRegion":"SE-BD","DestCityName":"Munich","FlightTimeHour":12.868315615788452,"FlightDelayMin":0}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"KFVIHZF","DestCountry":"CH","OriginWeather":"Cloudy","OriginCityName":"Warsaw","AvgTicketPrice":715.3965870162746,"DistanceMiles":642.1409366028741,"FlightDelay":false,"DestWeather":"Cloudy","Dest":"Zurich Airport","FlightDelayType":"No Delay","OriginCountry":"PL","dayOfWeek":6,"DistanceKilometers":1033.425663476216,"timestamp":"2019-04-28T01:59:45","DestLocation":{"lat":"47.464699","lon":"8.54917"},"DestAirportID":"ZRH","Carrier":"Kibana Airlines","Cancelled":false,"FlightTimeMin":49.21074587981981,"Origin":"Warsaw Chopin Airport","OriginLocation":{"lat":"52.16569901","lon":"20.96710014"},"DestRegion":"CH-ZH","OriginAirportID":"WAW","OriginRegion":"PL-MZ","DestCityName":"Zurich","FlightTimeHour":0.8201790979969968,"FlightDelayMin":0}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"HQFQ9ZT","DestCountry":"JP","OriginWeather":"Clear","OriginCityName":"Berlin","AvgTicketPrice":1189.0877702830553,"DistanceMiles":5522.091533843584,"FlightDelay":true,"DestWeather":"Cloudy","Dest":"Chubu Centrair International Airport","FlightDelayType":"NAS Delay","OriginCountry":"DE","dayOfWeek":6,"DistanceKilometers":8886.94487744197,"timestamp":"2019-04-28T02:59:36","DestLocation":{"lat":"34.85839844","lon":"136.8049927"},"DestAirportID":"NGO","Carrier":"ES-Air","Cancelled":false,"FlightTimeMin":817.4629918294647,"Origin":"Berlin-Tegel Airport","OriginLocation":{"lat":"52.5597","lon":"13.2877"},"DestRegion":"SE-BD","OriginAirportID":"TXL","OriginRegion":"DE-BE","DestCityName":"Tokoname","FlightTimeHour":13.624383197157746,"FlightDelayMin":225}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"LXAC607","DestCountry":"IN","OriginWeather":"Rain","OriginCityName":"Milan","AvgTicketPrice":852.9239643987471,"DistanceMiles":4404.211754114683,"FlightDelay":false,"DestWeather":"Sunny","Dest":"Rajiv Gandhi International Airport","FlightDelayType":"No Delay","OriginCountry":"IT","dayOfWeek":6,"DistanceKilometers":7087.89176121394,"timestamp":"2019-04-28T01:30:48","DestLocation":{"lat":"17.23131752","lon":"78.42985535"},"DestAirportID":"HYD","Carrier":"JetBeats","Cancelled":false,"FlightTimeMin":393.7717645118856,"Origin":"Malpensa International Airport","OriginLocation":{"lat":"45.6306","lon":"8.72811"},"DestRegion":"SE-BD","OriginAirportID":"MI12","OriginRegion":"IT-25","DestCityName":"Hyderabad","FlightTimeHour":6.56286274186476,"FlightDelayMin":0}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"R5B3U8U","DestCountry":"IT","OriginWeather":"Cloudy","OriginCityName":"Bangalore","AvgTicketPrice":606.6314009756906,"DistanceMiles":4393.854941857616,"FlightDelay":true,"DestWeather":"Clear","Dest":"Treviso-Sant'Angelo Airport","FlightDelayType":"NAS Delay","OriginCountry":"IN","dayOfWeek":6,"DistanceKilometers":7071.224087548903,"timestamp":"2019-04-28T14:39:15","DestLocation":{"lat":"45.648399","lon":"12.1944"},"DestAirportID":"TV01","Carrier":"JetBeats","Cancelled":false,"FlightTimeMin":593.5612043774452,"Origin":"Kempegowda International Airport","OriginLocation":{"lat":"13.1979","lon":"77.706299"},"DestRegion":"IT-34","OriginAirportID":"BLR","OriginRegion":"SE-BD","DestCityName":"Treviso","FlightTimeHour":9.892686739624086,"FlightDelayMin":240}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"5VW8BP5","DestCountry":"US","OriginWeather":"Sunny","OriginCityName":"Quito","AvgTicketPrice":505.39482886384485,"DistanceMiles":2689.049503715181,"FlightDelay":false,"DestWeather":"Cloudy","Dest":"Washington Dulles International Airport","FlightDelayType":"No Delay","OriginCountry":"EC","dayOfWeek":6,"DistanceKilometers":4327.605684507004,"timestamp":"2019-04-28T03:30:43","DestLocation":{"lat":"38.94449997","lon":"-77.45580292"},"DestAirportID":"IAD","Carrier":"Kibana Airlines","Cancelled":false,"FlightTimeMin":216.3802842253502,"Origin":"Mariscal Sucre International Airport","OriginLocation":{"lat":"-0.129166667","lon":"-78.3575"},"DestRegion":"US-DC","OriginAirportID":"UIO","OriginRegion":"SE-BD","DestCityName":"Washington","FlightTimeHour":3.6063380704225034,"FlightDelayMin":0}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"T6MIMVU","DestCountry":"ZA","OriginWeather":"Cloudy","OriginCityName":"Toronto","AvgTicketPrice":574.4829758539073,"DistanceMiles":8303.737614811667,"FlightDelay":false,"DestWeather":"Clear","Dest":"OR Tambo International Airport","FlightDelayType":"No Delay","OriginCountry":"CA","dayOfWeek":6,"DistanceKilometers":13363.570307971468,"timestamp":"2019-04-28T09:36:43","DestLocation":{"lat":"-26.1392","lon":"28.246"},"DestAirportID":"JNB","Carrier":"JetBeats","Cancelled":false,"FlightTimeMin":1027.966946767036,"Origin":"Lester B. Pearson International Airport","OriginLocation":{"lat":"43.67720032","lon":"-79.63059998"},"DestRegion":"SE-BD","OriginAirportID":"YYZ","OriginRegion":"CA-ON","DestCityName":"Johannesburg","FlightTimeHour":17.132782446117268,"FlightDelayMin":0}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"LL7XXP5","DestCountry":"AU","OriginWeather":"Clear","OriginCityName":"Seoul","AvgTicketPrice":1106.1566264095227,"DistanceMiles":5163.178442539636,"FlightDelay":false,"DestWeather":"Cloudy","Dest":"Sydney Kingsford Smith International Airport","FlightDelayType":"No Delay","OriginCountry":"KR","dayOfWeek":6,"DistanceKilometers":8309.33024743051,"timestamp":"2019-04-28T02:07:52","DestLocation":{"lat":"-33.94609833","lon":"151.177002"},"DestAirportID":"SYD","Carrier":"JetBeats","Cancelled":false,"FlightTimeMin":437.3331709173952,"Origin":"Gimpo International Airport","OriginLocation":{"lat":"37.5583","lon":"126.791"},"DestRegion":"SE-BD","OriginAirportID":"GMP","OriginRegion":"SE-BD","DestCityName":"Sydney","FlightTimeHour":7.288886181956586,"FlightDelayMin":0}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"HZN2WA1","DestCountry":"CN","OriginWeather":"Rain","OriginCityName":"Shanghai","AvgTicketPrice":233.29421474057222,"DistanceMiles":28.03511295292996,"FlightDelay":false,"DestWeather":"Cloudy","Dest":"Shanghai Pudong International Airport","FlightDelayType":"No Delay","OriginCountry":"CN","dayOfWeek":6,"DistanceKilometers":45.11814082012012,"timestamp":"2019-04-28T07:29:15","DestLocation":{"lat":"31.14340019","lon":"121.8050003"},"DestAirportID":"PVG","Carrier":"Kibana Airlines","Cancelled":false,"FlightTimeMin":3.4706262169323168,"Origin":"Shanghai Hongqiao International Airport","OriginLocation":{"lat":"31.19790077","lon":"121.3359985"},"DestRegion":"SE-BD","OriginAirportID":"SHA","OriginRegion":"SE-BD","DestCityName":"Shanghai","FlightTimeHour":0.05784377028220528,"FlightDelayMin":0}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"JO1PS1L","DestCountry":"RU","OriginWeather":"Sunny","OriginCityName":"Belogorsk","AvgTicketPrice":354.64236063211916,"DistanceMiles":0,"FlightDelay":false,"DestWeather":"Cloudy","Dest":"Ukrainka Air Base","FlightDelayType":"No Delay","OriginCountry":"RU","dayOfWeek":6,"DistanceKilometers":0,"timestamp":"2019-04-28T14:17:10","DestLocation":{"lat":"51.169997","lon":"128.445007"},"DestAirportID":"XHBU","Carrier":"ES-Air","Cancelled":false,"FlightTimeMin":0,"Origin":"Ukrainka Air Base","OriginLocation":{"lat":"51.169997","lon":"128.445007"},"DestRegion":"RU-AMU","OriginAirportID":"XHBU","OriginRegion":"RU-AMU","DestCityName":"Belogorsk","FlightTimeHour":0,"FlightDelayMin":0}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"4C1WNIV","DestCountry":"DK","OriginWeather":"Sunny","OriginCityName":"Bari","AvgTicketPrice":775.9765840481864,"DistanceMiles":1017.6506075260256,"FlightDelay":false,"DestWeather":"Cloudy","Dest":"Copenhagen Kastrup Airport","FlightDelayType":"No Delay","OriginCountry":"IT","dayOfWeek":6,"DistanceKilometers":1637.7498993183642,"timestamp":"2019-04-28T15:10:41","DestLocation":{"lat":"55.61790085","lon":"12.65600014"},"DestAirportID":"CPH","Carrier":"JetBeats","Cancelled":false,"FlightTimeMin":125.98076148602802,"Origin":"Bari Karol Wojty__a Airport","OriginLocation":{"lat":"41.138901","lon":"16.760599"},"DestRegion":"DK-84","OriginAirportID":"BA02","OriginRegion":"IT-75","DestCityName":"Copenhagen","FlightTimeHour":2.099679358100467,"FlightDelayMin":0}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"ITJ5CEQ","DestCountry":"US","OriginWeather":"Cloudy","OriginCityName":"Naples","AvgTicketPrice":724.1725161120967,"DistanceMiles":5794.301714692558,"FlightDelay":true,"DestWeather":"Clear","Dest":"Seattle Tacoma International Airport","FlightDelayType":"Carrier Delay","OriginCountry":"IT","dayOfWeek":6,"DistanceKilometers":9325.02469873018,"timestamp":"2019-04-28T08:01:44","DestLocation":{"lat":"47.44900131","lon":"-122.3089981"},"DestAirportID":"SEA","Carrier":"JetBeats","Cancelled":false,"FlightTimeMin":706.251234936509,"Origin":"Naples International Airport","OriginLocation":{"lat":"40.886002","lon":"14.2908"},"DestRegion":"US-WA","OriginAirportID":"NA01","OriginRegion":"IT-72","DestCityName":"Seattle","FlightTimeHour":11.770853915608484,"FlightDelayMin":240}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"OM87D31","DestCountry":"RU","OriginWeather":"Damaging Wind","OriginCityName":"Los Angeles","AvgTicketPrice":737.2994469493347,"DistanceMiles":5310.324424041539,"FlightDelay":false,"DestWeather":"Sunny","Dest":"Ukrainka Air Base","FlightDelayType":"No Delay","OriginCountry":"US","dayOfWeek":6,"DistanceKilometers":8546.138749884707,"timestamp":"2019-04-28T08:58:07","DestLocation":{"lat":"51.169997","lon":"128.445007"},"DestAirportID":"XHBU","Carrier":"Logstash Airways","Cancelled":false,"FlightTimeMin":406.95898808974795,"Origin":"Los Angeles International Airport","OriginLocation":{"lat":"33.94250107","lon":"-118.4079971"},"DestRegion":"RU-AMU","OriginAirportID":"LAX","OriginRegion":"US-CA","DestCityName":"Belogorsk","FlightTimeHour":6.782649801495799,"FlightDelayMin":0}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"JO10S8D","DestCountry":"IT","OriginWeather":"Rain","OriginCityName":"Olenegorsk","AvgTicketPrice":1084.7325423830152,"DistanceMiles":1769.2049279598184,"FlightDelay":false,"DestWeather":"Clear","Dest":"Verona Villafranca Airport","FlightDelayType":"No Delay","OriginCountry":"RU","dayOfWeek":6,"DistanceKilometers":2847.259335582566,"timestamp":"2019-04-28T12:14:45","DestLocation":{"lat":"45.395699","lon":"10.8885"},"DestAirportID":"VR10","Carrier":"JetBeats","Cancelled":false,"FlightTimeMin":237.27161129854719,"Origin":"Olenya Air Base","OriginLocation":{"lat":"68.15180206","lon":"33.46390152"},"DestRegion":"IT-34","OriginAirportID":"XLMO","OriginRegion":"RU-MUR","DestCityName":"Verona","FlightTimeHour":3.9545268549757866,"FlightDelayMin":0}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"8Y1MHYP","DestCountry":"KR","OriginWeather":"Rain","OriginCityName":"Mumbai","AvgTicketPrice":709.7353992265661,"DistanceMiles":3451.3528435038916,"FlightDelay":false,"DestWeather":"Rain","Dest":"Incheon International Airport","FlightDelayType":"No Delay","OriginCountry":"IN","dayOfWeek":6,"DistanceKilometers":5554.4139905759275,"timestamp":"2019-04-28T20:07:04","DestLocation":{"lat":"37.46910095","lon":"126.4509964"},"DestAirportID":"ICN","Carrier":"ES-Air","Cancelled":false,"FlightTimeMin":396.7438564697091,"Origin":"Chhatrapati Shivaji International Airport","OriginLocation":{"lat":"19.08869934","lon":"72.86789703"},"DestRegion":"SE-BD","OriginAirportID":"BOM","OriginRegion":"SE-BD","DestCityName":"Seoul","FlightTimeHour":6.612397607828485,"FlightDelayMin":0}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"PUFW0I9","DestCountry":"IT","OriginWeather":"Sunny","OriginCityName":"Bergamo","AvgTicketPrice":202.4631864316891,"DistanceMiles":60.60689364881755,"FlightDelay":false,"DestWeather":"Clear","Dest":"Verona Villafranca Airport","FlightDelayType":"No Delay","OriginCountry":"IT","dayOfWeek":6,"DistanceKilometers":97.53734065236263,"timestamp":"2019-04-28T08:04:19","DestLocation":{"lat":"45.395699","lon":"10.8885"},"DestAirportID":"VR10","Carrier":"ES-Air","Cancelled":false,"FlightTimeMin":8.12811172103022,"Origin":"Il Caravaggio International Airport","OriginLocation":{"lat":"45.673901","lon":"9.70417"},"DestRegion":"IT-34","OriginAirportID":"BG01","OriginRegion":"IT-25","DestCityName":"Verona","FlightTimeHour":0.135468528683837,"FlightDelayMin":0}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"0YUI45V","DestCountry":"CA","OriginWeather":"Cloudy","OriginCityName":"Verona","AvgTicketPrice":824.148394697551,"DistanceMiles":4585.376414414682,"FlightDelay":false,"DestWeather":"Damaging Wind","Dest":"Winnipeg / James Armstrong Richardson International Airport","FlightDelayType":"No Delay","OriginCountry":"IT","dayOfWeek":6,"DistanceKilometers":7379.448020279781,"timestamp":"2019-04-28T23:03:36","DestLocation":{"lat":"49.90999985","lon":"-97.23989868"},"DestAirportID":"YWG","Carrier":"Logstash Airways","Cancelled":true,"FlightTimeMin":527.1034300199843,"Origin":"Verona Villafranca Airport","OriginLocation":{"lat":"45.395699","lon":"10.8885"},"DestRegion":"CA-MB","OriginAirportID":"VR10","OriginRegion":"IT-34","DestCityName":"Winnipeg","FlightTimeHour":8.785057166999739,"FlightDelayMin":0}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"A9A6GSS","DestCountry":"GB","OriginWeather":"Cloudy","OriginCityName":"Frankfurt am Main","AvgTicketPrice":1091.8211102327573,"DistanceMiles":410.20462338579114,"FlightDelay":true,"DestWeather":"Rain","Dest":"London Luton Airport","FlightDelayType":"Carrier Delay","OriginCountry":"DE","dayOfWeek":6,"DistanceKilometers":660.1603494181827,"timestamp":"2019-04-28T08:24:20","DestLocation":{"lat":"51.87469864","lon":"-0.368333012"},"DestAirportID":"LTN","Carrier":"Kibana Airlines","Cancelled":false,"FlightTimeMin":107.15431067272733,"Origin":"Frankfurt am Main Airport","OriginLocation":{"lat":"50.033333","lon":"8.570556"},"DestRegion":"GB-ENG","OriginAirportID":"FRA","OriginRegion":"DE-HE","DestCityName":"London","FlightTimeHour":1.7859051778787889,"FlightDelayMin":60}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"8C7YW6V","DestCountry":"RU","OriginWeather":"Damaging Wind","OriginCityName":"Belleville","AvgTicketPrice":990.1119988904413,"DistanceMiles":5225.822309705396,"FlightDelay":true,"DestWeather":"Clear","Dest":"Sheremetyevo International Airport","FlightDelayType":"Security Delay","OriginCountry":"US","dayOfWeek":6,"DistanceKilometers":8410.145779190521,"timestamp":"2019-04-28T10:51:28","DestLocation":{"lat":"55.972599","lon":"37.4146"},"DestAirportID":"SVO","Carrier":"JetBeats","Cancelled":false,"FlightTimeMin":730.8454815992101,"Origin":"Scott AFB/Midamerica Airport","OriginLocation":{"lat":"38.5452","lon":"-89.835197"},"DestRegion":"RU-MOS","OriginAirportID":"BLV","OriginRegion":"US-IL","DestCityName":"Moscow","FlightTimeHour":12.180758026653502,"FlightDelayMin":30}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"QT89ZO0","DestCountry":"IT","OriginWeather":"Rain","OriginCityName":"Olenegorsk","AvgTicketPrice":965.9504876434181,"DistanceMiles":1769.2049279598184,"FlightDelay":true,"DestWeather":"Clear","Dest":"Verona Villafranca Airport","FlightDelayType":"Carrier Delay","OriginCountry":"RU","dayOfWeek":6,"DistanceKilometers":2847.259335582566,"timestamp":"2019-04-28T21:59:45","DestLocation":{"lat":"45.395699","lon":"10.8885"},"DestAirportID":"VR10","Carrier":"JetBeats","Cancelled":false,"FlightTimeMin":408.8417577802333,"Origin":"Olenya Air Base","OriginLocation":{"lat":"68.15180206","lon":"33.46390152"},"DestRegion":"IT-34","OriginAirportID":"XLMO","OriginRegion":"RU-MUR","DestCityName":"Verona","FlightTimeHour":6.814029296337222,"FlightDelayMin":150}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"VYY4AMY","DestCountry":"CA","OriginWeather":"Clear","OriginCityName":"Rome","AvgTicketPrice":720.6455705062402,"DistanceMiles":4188.312375179007,"FlightDelay":false,"DestWeather":"Sunny","Dest":"Ottawa Macdonald-Cartier International Airport","FlightDelayType":"No Delay","OriginCountry":"IT","dayOfWeek":6,"DistanceKilometers":6740.435391120085,"timestamp":"2019-04-28T01:40:02","DestLocation":{"lat":"45.32249832","lon":"-75.66919708"},"DestAirportID":"YOW","Carrier":"JetBeats","Cancelled":false,"FlightTimeMin":320.97311386286117,"Origin":"Leonardo da Vinci___Fiumicino Airport","OriginLocation":{"lat":"41.8002778","lon":"12.2388889"},"DestRegion":"CA-ON","OriginAirportID":"RM11","OriginRegion":"IT-62","DestCityName":"Ottawa","FlightTimeHour":5.349551897714353,"FlightDelayMin":0}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"1EWKL6T","DestCountry":"CN","OriginWeather":"Sunny","OriginCityName":"Bangor","AvgTicketPrice":656.266589789506,"DistanceMiles":7161.285858697714,"FlightDelay":false,"DestWeather":"Hail","Dest":"Shanghai Hongqiao International Airport","FlightDelayType":"No Delay","OriginCountry":"US","dayOfWeek":6,"DistanceKilometers":11524.972428980014,"timestamp":"2019-04-28T07:32:13","DestLocation":{"lat":"31.19790077","lon":"121.3359985"},"DestAirportID":"SHA","Carrier":"JetBeats","Cancelled":false,"FlightTimeMin":640.2762460544452,"Origin":"Bangor International Airport","OriginLocation":{"lat":"44.80739975","lon":"-68.82810211"},"DestRegion":"SE-BD","OriginAirportID":"BGR","OriginRegion":"US-ME","DestCityName":"Shanghai","FlightTimeHour":10.671270767574088,"FlightDelayMin":0}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"V8PZCYK","DestCountry":"CA","OriginWeather":"Clear","OriginCityName":"Belogorsk","AvgTicketPrice":736.8890632067493,"DistanceMiles":4969.643638585388,"FlightDelay":false,"DestWeather":"Clear","Dest":"Winnipeg / James Armstrong Richardson International Airport","FlightDelayType":"No Delay","OriginCountry":"RU","dayOfWeek":6,"DistanceKilometers":7997.866171895563,"timestamp":"2019-04-28T13:11:28","DestLocation":{"lat":"49.90999985","lon":"-97.23989868"},"DestAirportID":"YWG","Carrier":"Kibana Airlines","Cancelled":false,"FlightTimeMin":470.46271599385665,"Origin":"Ukrainka Air Base","OriginLocation":{"lat":"51.169997","lon":"128.445007"},"DestRegion":"CA-MB","OriginAirportID":"XHBU","OriginRegion":"RU-AMU","DestCityName":"Winnipeg","FlightTimeHour":7.841045266564278,"FlightDelayMin":0}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"Q60XHPQ","DestCountry":"CN","OriginWeather":"Clear","OriginCityName":"Portland","AvgTicketPrice":727.2546307307979,"DistanceMiles":7227.547484020332,"FlightDelay":false,"DestWeather":"Clear","Dest":"Shanghai Pudong International Airport","FlightDelayType":"No Delay","OriginCountry":"US","dayOfWeek":6,"DistanceKilometers":11631.61017812322,"timestamp":"2019-04-28T19:42:41","DestLocation":{"lat":"31.14340019","lon":"121.8050003"},"DestAirportID":"PVG","Carrier":"Kibana Airlines","Cancelled":false,"FlightTimeMin":612.1900093749063,"Origin":"Portland International Jetport Airport","OriginLocation":{"lat":"43.64619827","lon":"-70.30930328"},"DestRegion":"SE-BD","OriginAirportID":"PWM","OriginRegion":"US-ME","DestCityName":"Shanghai","FlightTimeHour":10.203166822915104,"FlightDelayMin":0}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"D8X0NQL","DestCountry":"MX","OriginWeather":"Rain","OriginCityName":"Frankfurt am Main","AvgTicketPrice":1175.106976311751,"DistanceMiles":5944.542718142312,"FlightDelay":true,"DestWeather":"Damaging Wind","Dest":"Licenciado Benito Juarez International Airport","FlightDelayType":"Carrier Delay","OriginCountry":"DE","dayOfWeek":6,"DistanceKilometers":9566.814156186021,"timestamp":"2019-04-28T06:20:04","DestLocation":{"lat":"19.4363","lon":"-99.072098"},"DestAirportID":"AICM","Carrier":"Logstash Airways","Cancelled":false,"FlightTimeMin":728.5165345361063,"Origin":"Frankfurt am Main Airport","OriginLocation":{"lat":"50.033333","lon":"8.570556"},"DestRegion":"MX-DIF","OriginAirportID":"FRA","OriginRegion":"DE-HE","DestCityName":"Mexico City","FlightTimeHour":12.141942242268438,"FlightDelayMin":225}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"8QXNGOT","DestCountry":"IT","OriginWeather":"Damaging Wind","OriginCityName":"Osaka","AvgTicketPrice":632.241039145645,"DistanceMiles":6047.906670679155,"FlightDelay":false,"DestWeather":"Damaging Wind","Dest":"Turin Airport","FlightDelayType":"No Delay","OriginCountry":"JP","dayOfWeek":6,"DistanceKilometers":9733.162313017474,"timestamp":"2019-04-28T11:05:10","DestLocation":{"lat":"45.200802","lon":"7.64963"},"DestAirportID":"TO11","Carrier":"JetBeats","Cancelled":false,"FlightTimeMin":486.6581156508737,"Origin":"Kansai International Airport","OriginLocation":{"lat":"34.4272995","lon":"135.2440033"},"DestRegion":"IT-21","OriginAirportID":"KIX","OriginRegion":"SE-BD","DestCityName":"Torino","FlightTimeHour":8.110968594181228,"FlightDelayMin":0}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"JJDS24V","DestCountry":"RU","OriginWeather":"Rain","OriginCityName":"Bergamo","AvgTicketPrice":1026.6855387495166,"DistanceMiles":1392.7225270153913,"FlightDelay":false,"DestWeather":"Cloudy","Dest":"Sheremetyevo International Airport","FlightDelayType":"No Delay","OriginCountry":"IT","dayOfWeek":6,"DistanceKilometers":2241.369642517058,"timestamp":"2019-04-28T03:04:35","DestLocation":{"lat":"55.972599","lon":"37.4146"},"DestAirportID":"SVO","Carrier":"Logstash Airways","Cancelled":false,"FlightTimeMin":124.5205356953921,"Origin":"Il Caravaggio International Airport","OriginLocation":{"lat":"45.673901","lon":"9.70417"},"DestRegion":"RU-MOS","OriginAirportID":"BG01","OriginRegion":"IT-25","DestCityName":"Moscow","FlightTimeHour":2.0753422615898685,"FlightDelayMin":0}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"UJF6TYK","DestCountry":"RU","OriginWeather":"Rain","OriginCityName":"Los Angeles","AvgTicketPrice":548.3621793628536,"DistanceMiles":5310.324424041539,"FlightDelay":false,"DestWeather":"Cloudy","Dest":"Ukrainka Air Base","FlightDelayType":"No Delay","OriginCountry":"US","dayOfWeek":6,"DistanceKilometers":8546.138749884707,"timestamp":"2019-04-28T17:06:34","DestLocation":{"lat":"51.169997","lon":"128.445007"},"DestAirportID":"XHBU","Carrier":"JetBeats","Cancelled":false,"FlightTimeMin":569.7425833256472,"Origin":"Los Angeles International Airport","OriginLocation":{"lat":"33.94250107","lon":"-118.4079971"},"DestRegion":"RU-AMU","OriginAirportID":"LAX","OriginRegion":"US-CA","DestCityName":"Belogorsk","FlightTimeHour":9.49570972209412,"FlightDelayMin":0}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"UCOJXQF","DestCountry":"CA","OriginWeather":"Damaging Wind","OriginCityName":"Durban","AvgTicketPrice":705.0817702762915,"DistanceMiles":9428.703163976606,"FlightDelay":true,"DestWeather":"Rain","Dest":"Winnipeg / James Armstrong Richardson International Airport","FlightDelayType":"NAS Delay","OriginCountry":"ZA","dayOfWeek":6,"DistanceKilometers":15174.026864726768,"timestamp":"2019-04-28T22:14:01","DestLocation":{"lat":"49.90999985","lon":"-97.23989868"},"DestAirportID":"YWG","Carrier":"Logstash Airways","Cancelled":false,"FlightTimeMin":922.5898155721628,"Origin":"King Shaka International Airport","OriginLocation":{"lat":"-29.61444444","lon":"31.11972222"},"DestRegion":"CA-MB","OriginAirportID":"DUR","OriginRegion":"SE-BD","DestCityName":"Winnipeg","FlightTimeHour":15.376496926202714,"FlightDelayMin":30}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"FFEVPM9","DestCountry":"CH","OriginWeather":"Sunny","OriginCityName":"Vienna","AvgTicketPrice":537.5841160286202,"DistanceMiles":375.91600977352937,"FlightDelay":false,"DestWeather":"Rain","Dest":"Zurich Airport","FlightDelayType":"No Delay","OriginCountry":"AT","dayOfWeek":6,"DistanceKilometers":604.9781748329709,"timestamp":"2019-04-28T18:43:51","DestLocation":{"lat":"47.464699","lon":"8.54917"},"DestAirportID":"ZRH","Carrier":"Kibana Airlines","Cancelled":false,"FlightTimeMin":30.248908741648545,"Origin":"Vienna International Airport","OriginLocation":{"lat":"48.11029816","lon":"16.56970024"},"DestRegion":"CH-ZH","OriginAirportID":"VIE","OriginRegion":"AT-9","DestCityName":"Zurich","FlightTimeHour":0.5041484790274757,"FlightDelayMin":0}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"NH7VL6M","DestCountry":"JP","OriginWeather":"Hail","OriginCityName":"Rome","AvgTicketPrice":776.7301294727417,"DistanceMiles":6169.519973545765,"FlightDelay":true,"DestWeather":"Rain","Dest":"Narita International Airport","FlightDelayType":"Carrier Delay","OriginCountry":"IT","dayOfWeek":6,"DistanceKilometers":9928.879952306037,"timestamp":"2019-04-28T05:42:05","DestLocation":{"lat":"35.76470184","lon":"140.3860016"},"DestAirportID":"NRT","Carrier":"JetBeats","Cancelled":false,"FlightTimeMin":706.4439976153019,"Origin":"Leonardo da Vinci___Fiumicino Airport","OriginLocation":{"lat":"41.8002778","lon":"12.2388889"},"DestRegion":"SE-BD","OriginAirportID":"RM11","OriginRegion":"IT-62","DestCityName":"Tokyo","FlightTimeHour":11.774066626921698,"FlightDelayMin":210}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"QNKW3RH","DestCountry":"US","OriginWeather":"Thunder & Lightning","OriginCityName":"Cape Town","AvgTicketPrice":895.6816497069224,"DistanceMiles":9542.103741796594,"FlightDelay":true,"DestWeather":"Rain","Dest":"Tucson International Airport","FlightDelayType":"NAS Delay","OriginCountry":"ZA","dayOfWeek":6,"DistanceKilometers":15356.5274042379,"timestamp":"2019-04-28T23:21:23","DestLocation":{"lat":"32.11610031","lon":"-110.9410019"},"DestAirportID":"TUS","Carrier":"Logstash Airways","Cancelled":false,"FlightTimeMin":928.2382844335738,"Origin":"Cape Town International Airport","OriginLocation":{"lat":"-33.96480179","lon":"18.60169983"},"DestRegion":"US-AZ","OriginAirportID":"CPT","OriginRegion":"SE-BD","DestCityName":"Tucson","FlightTimeHour":15.470638073892896,"FlightDelayMin":120}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"CF0DLIB","DestCountry":"AT","OriginWeather":"Cloudy","OriginCityName":"St Louis","AvgTicketPrice":571.5885601985526,"DistanceMiles":4965.899046782677,"FlightDelay":false,"DestWeather":"Clear","Dest":"Vienna International Airport","FlightDelayType":"No Delay","OriginCountry":"US","dayOfWeek":6,"DistanceKilometers":7991.839835545421,"timestamp":"2019-04-28T08:15:58","DestLocation":{"lat":"48.11029816","lon":"16.56970024"},"DestAirportID":"VIE","Carrier":"Kibana Airlines","Cancelled":false,"FlightTimeMin":443.9911019747456,"Origin":"St Louis Lambert International Airport","OriginLocation":{"lat":"38.748697","lon":"-90.370003"},"DestRegion":"AT-9","OriginAirportID":"STL","OriginRegion":"US-MO","DestCityName":"Vienna","FlightTimeHour":7.399851699579093,"FlightDelayMin":0}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"0PQLKPQ","DestCountry":"JP","OriginWeather":"Clear","OriginCityName":"Hyderabad","AvgTicketPrice":680.6255274994425,"DistanceMiles":3942.354004380302,"FlightDelay":false,"DestWeather":"Sunny","Dest":"Tokyo Haneda International Airport","FlightDelayType":"No Delay","OriginCountry":"IN","dayOfWeek":6,"DistanceKilometers":6344.603762825413,"timestamp":"2019-04-28T20:06:18","DestLocation":{"lat":"35.552299","lon":"139.779999"},"DestAirportID":"HND","Carrier":"ES-Air","Cancelled":false,"FlightTimeMin":576.7821602568557,"Origin":"Rajiv Gandhi International Airport","OriginLocation":{"lat":"17.23131752","lon":"78.42985535"},"DestRegion":"SE-BD","OriginAirportID":"HYD","OriginRegion":"SE-BD","DestCityName":"Tokyo","FlightTimeHour":9.613036004280929,"FlightDelayMin":0}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"3MOUQWO","DestCountry":"US","OriginWeather":"Sunny","OriginCityName":"Boston","AvgTicketPrice":224.21289875496316,"DistanceMiles":1433.1167464617286,"FlightDelay":true,"DestWeather":"Clear","Dest":"Wichita Mid Continent Airport","FlightDelayType":"Carrier Delay","OriginCountry":"US","dayOfWeek":6,"DistanceKilometers":2306.3778372177044,"timestamp":"2019-04-28T03:09:59","DestLocation":{"lat":"37.64989853","lon":"-97.43309784"},"DestAirportID":"ICT","Carrier":"Kibana Airlines","Cancelled":false,"FlightTimeMin":143.13210206765024,"Origin":"General Edward Lawrence Logan International Airport","OriginLocation":{"lat":"42.36429977","lon":"-71.00520325"},"DestRegion":"US-KS","OriginAirportID":"BOS","OriginRegion":"US-MA","DestCityName":"Wichita","FlightTimeHour":2.3855350344608373,"FlightDelayMin":15}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"J9P7G64","DestCountry":"IN","OriginWeather":"Rain","OriginCityName":"Seoul","AvgTicketPrice":500.3885016709913,"DistanceMiles":3221.639539065269,"FlightDelay":false,"DestWeather":"Cloudy","Dest":"Rajiv Gandhi International Airport","FlightDelayType":"No Delay","OriginCountry":"KR","dayOfWeek":6,"DistanceKilometers":5184.726262357457,"timestamp":"2019-04-28T19:38:41","DestLocation":{"lat":"17.23131752","lon":"78.42985535"},"DestAirportID":"HYD","Carrier":"ES-Air","Cancelled":false,"FlightTimeMin":246.8917267789265,"Origin":"Incheon International Airport","OriginLocation":{"lat":"37.46910095","lon":"126.4509964"},"DestRegion":"SE-BD","OriginAirportID":"ICN","OriginRegion":"SE-BD","DestCityName":"Hyderabad","FlightTimeHour":4.114862112982109,"FlightDelayMin":0}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"RQ5H8VJ","DestCountry":"CO","OriginWeather":"Clear","OriginCityName":"Bogota","AvgTicketPrice":390.4114514413162,"DistanceMiles":0,"FlightDelay":false,"DestWeather":"Sunny","Dest":"El Dorado International Airport","FlightDelayType":"No Delay","OriginCountry":"CO","dayOfWeek":6,"DistanceKilometers":0,"timestamp":"2019-04-28T06:59:57","DestLocation":{"lat":"4.70159","lon":"-74.1469"},"DestAirportID":"BOG","Carrier":"ES-Air","Cancelled":false,"FlightTimeMin":0,"Origin":"El Dorado International Airport","OriginLocation":{"lat":"4.70159","lon":"-74.1469"},"DestRegion":"CO-CUN","OriginAirportID":"BOG","OriginRegion":"CO-CUN","DestCityName":"Bogota","FlightTimeHour":0,"FlightDelayMin":0}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"L7AIJW9","DestCountry":"IT","OriginWeather":"Damaging Wind","OriginCityName":"New Delhi","AvgTicketPrice":549.6659472901539,"DistanceMiles":3693.79804441938,"FlightDelay":false,"DestWeather":"Sunny","Dest":"Leonardo da Vinci___Fiumicino Airport","FlightDelayType":"No Delay","OriginCountry":"IN","dayOfWeek":6,"DistanceKilometers":5944.591719998063,"timestamp":"2019-04-28T23:20:52","DestLocation":{"lat":"41.8002778","lon":"12.2388889"},"DestAirportID":"RM11","Carrier":"Logstash Airways","Cancelled":false,"FlightTimeMin":349.681865882239,"Origin":"Indira Gandhi International Airport","OriginLocation":{"lat":"28.5665","lon":"77.103104"},"DestRegion":"IT-62","OriginAirportID":"DEL","OriginRegion":"SE-BD","DestCityName":"Rome","FlightTimeHour":5.828031098037316,"FlightDelayMin":0}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"EZ7DYZM","DestCountry":"CH","OriginWeather":"Rain","OriginCityName":"Zurich","AvgTicketPrice":428.54990722738944,"DistanceMiles":0,"FlightDelay":true,"DestWeather":"Rain","Dest":"Zurich Airport","FlightDelayType":"Late Aircraft Delay","OriginCountry":"CH","dayOfWeek":6,"DistanceKilometers":0,"timestamp":"2019-04-28T05:28:20","DestLocation":{"lat":"47.464699","lon":"8.54917"},"DestAirportID":"ZRH","Carrier":"Logstash Airways","Cancelled":false,"FlightTimeMin":120,"Origin":"Zurich Airport","OriginLocation":{"lat":"47.464699","lon":"8.54917"},"DestRegion":"CH-ZH","OriginAirportID":"ZRH","OriginRegion":"CH-ZH","DestCityName":"Zurich","FlightTimeHour":2,"FlightDelayMin":120}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"S3I625A","DestCountry":"FR","OriginWeather":"Cloudy","OriginCityName":"Catania","AvgTicketPrice":520.5221987171525,"DistanceMiles":1014.2188354597835,"FlightDelay":false,"DestWeather":"Heavy Fog","Dest":"Charles de Gaulle International Airport","FlightDelayType":"No Delay","OriginCountry":"IT","dayOfWeek":6,"DistanceKilometers":1632.2269975341899,"timestamp":"2019-04-28T17:22:49","DestLocation":{"lat":"49.01279831","lon":"2.549999952"},"DestAirportID":"CDG","Carrier":"ES-Air","Cancelled":true,"FlightTimeMin":81.6113498767095,"Origin":"Catania-Fontanarossa Airport","OriginLocation":{"lat":"37.466801","lon":"15.0664"},"DestRegion":"FR-J","OriginAirportID":"CT03","OriginRegion":"IT-82","DestCityName":"Paris","FlightTimeHour":1.360189164611825,"FlightDelayMin":0}
{"index":{"_index":"s_flights","_type":"_doc"}}
{"FlightNum":"8ABXIEF","DestCountry":"CA","OriginWeather":"Clear","OriginCityName":"Warsaw","AvgTicketPrice":629.122664400094,"DistanceMiles":4527.391333277357,"FlightDelay":false,"DestWeather":"Rain","Dest":"Winnipeg / James Armstrong Richardson International Airport","FlightDelayType":"No Delay","OriginCountry":"PL","dayOfWeek":6,"DistanceKilometers":7286.130077861916,"timestamp":"2019-04-28T05:51:08","DestLocation":{"lat":"49.90999985","lon":"-97.23989868"},"DestAirportID":"YWG","Carrier":"JetBeats","Cancelled":false,"FlightTimeMin":560.4715444509167,"Origin":"Warsaw Chopin Airport","OriginLocation":{"lat":"52.16569901","lon":"20.96710014"},"DestRegion":"CA-MB","OriginAirportID":"WAW","OriginRegion":"PL-MZ","DestCityName":"Winnipeg","FlightTimeHour":9.341192407515278,"FlightDelayMin":0}
ES操作纪录
以下操作均在 6.7.1版本中正常
文档
- https://www.elastic.co/guide/cn/elasticsearch/guide/current/index.html《Elasticsearch 权威指南》中文版(文档已经过时,只是因为是英文,方便快速入门)
- https://www.elastic.co/guide/en/elasticsearch/reference/6.7/getting-started.html 6.7的英文文档
basic
GET /?pretty
curl 'http://localhost:9200/?pretty'
正常返回类似如下结果
{
"name" : "id_Cdrf",
"cluster_name" : "docker-cluster",
"cluster_uuid" : "OVVjOYXmRLmH0_x6QnS6sw",
"version" : {
"number" : "6.7.1",
"build_flavor" : "default",
"build_type" : "docker",
"build_hash" : "2f32220",
"build_date" : "2019-04-02T15:59:27.961366Z",
"build_snapshot" : false,
"lucene_version" : "7.7.0",
"minimum_wire_compatibility_version" : "5.6.0",
"minimum_index_compatibility_version" : "5.0.0"
},
"tagline" : "You Know, for Search"
}
操作记录
所有操作都基于数据集合 s_flights
,详情查看文件 es-operation-datasource.md
。
默认查询全部实际上只返回前10条数据
数据说明
航班信息(注释后面是mapping的类型):
{
"FlightNum" : "EN9FHUD", //航班编号 keyword
"DestCountry" : "CA", //目的地国家名 keyword
"OriginWeather" : "Rain",//出发地天气 keyword
"OriginCityName" : "Detroit", // 出发地城市名 keyword
"AvgTicketPrice" : 798.6925673856011, // 平均机票价格 float
"DistanceMiles" : 1586.2909176475928,//出发地到目的地的英里数 float
"FlightDelay" : true, //航班是否延迟 boolean
"DestWeather" : "Rain", //目的地天气 keyword
"Dest" : "Edmonton International Airport",//目的地机场 keyword
"FlightDelayType" : "Security Delay", // 航班延迟类型 keyword
"OriginCountry" : "US", //出发地国家名 keyword
"dayOfWeek" : 6, //星期 integer
"DistanceKilometers" : 2552.8877705706477, //出发地到目的地的公里数 float
"timestamp" : "2019-04-28T06:25:17", //时间戳 date
"DestLocation" : {//目的地坐标 geo_point
"lat" : "53.30970001", //纬度
"lon" : "-113.5800018" //经度
},
"DestAirportID" : "CYEG", //目的地机场ID keyword
"Carrier" : "Kibana Airlines", //航空公司名 keyword
"Cancelled" : false, //是否取消航班 boolean
"FlightTimeMin" : 451.3759823515883, //航班飞行最小分钟数 float
"Origin" : "Detroit Metropolitan Wayne County Airport",//出发地机场 keyword
"OriginLocation" : {//出发地坐标 geo_point
"lat" : "42.21239853",//纬度
"lon" : "-83.35340118"//经度
},
"DestRegion" : "CA-AB",//目的地区域 keyword
"OriginAirportID" : "DTW", //出发地的机场ID keyword
"OriginRegion" : "US-MI", //出发地区域 keyword
"DestCityName" : "Edmonton", //目的地城市名称 keyword
"FlightTimeHour" : 7.522933039193138, //航班飞行小时数 keyword
"FlightDelayMin" : 255 //航班延迟最小分钟数 integer
}
操作记录
由于数据体数据太多,所以需要对数据返回进行如下方式过滤
如下只返回定义的五个属性
轻量查询方式:
GET /s_flights/_doc/_search?_source=FlightNum,Origin,OriginCountry,Dest,DestCountry
请求体方式:
GET /s_flights/_doc/_search
{
"_source": [
"FlightNum",
"Origin",
"OriginCountry",
"Dest",
"DestCountry"
]
}
添加数据
mapping定义的数据不需要所有都填写
添加单独一条数据
PUT /s_flights/_doc/100
{
"FlightNum": "C12345A",
"Origin": "重庆",
"Dest": "北京"
}
添加单独一条数据自动生成 id
POST /s_flights/_doc/
{
"FlightNum": "C12345A",
"Origin": "重庆",
"Dest": "北京"
}
确保是添加新文档,而不是更新文档
PUT /s_flights/_doc/BxOIj2oBXEJSGxQ5yn4k?op_type=create
{
"FlightNum": "C12345A",
"Origin": "重庆",
"Dest": "北京"
}
PUT /s_flights/_doc/BxOIj2oBXEJSGxQ5yn4k/_create
{
"FlightNum": "C12345A",
"Origin": "重庆",
"Dest": "北京"
}
doc as upsert
POST /s_flights/_doc/1
{
"doc": {
"FlightNum": "C123333345A",
"Origin": "重222庆",
"Dest": "北京",
"bb":11
},
"doc_as_upsert": true
}
存在属性再更新就会返回 noop(no operation) 操作
POST /s_flights/_doc/1/_update
{
"doc" : {
"moreInfo":{
"counter":1
}
}
}
批量插入数据
POST _bulk
{"create":{"_index":"s_flights","_type":"_doc","_id":"101"}}
{"FlightNum":"C12345B","Origin":"重庆","Dest":"上海"}
{"create":{"_index":"s_flights","_type":"_doc","_id":"102"}}
{"FlightNum":"C12345C","Origin":"重庆","Dest":"武汉"}
删除数据
删除数据_id
为100的
DELETE /s_flights/_doc/100
批量删除数据
POST _bulk
{"delete":{"_index":"s_flights","_type":"_doc","_id":"101"}}
{"delete":{"_index":"s_flights","_type":"_doc","_id":"102"}}
修改(更新)数据
https://www.elastic.co/guide/en/elasticsearch/reference/6.7/docs-update.html
更新或添加数据
POST /s_flights/_doc/1/_update
{
"doc" : {
"moreInfo":{
"tags" : [ "airline","flight","aeroplane","airplane"],
"counter":1,
"memo_1":""
}
}
}
GET /s_flights/_doc/1?_source=moreInfo
脚本方式更新字段值:
POST s_flights/_doc/1/_update
{
"script" : "ctx._source.moreInfo.counter+=1"
}
POST s_flights/_doc/1/_update
{
"script" : "ctx._source.moreInfo.memo_1='good time'"
}
GET /s_flights/_doc/1?_source=moreInfo
如果数据不存在,则先使用upsert
创建文档,然后再次执行,则会执行脚本进行递增。
DELETE s_flights/_doc/1
POST s_flights/_doc/1/_update
{
"script": {
"source": "ctx._source.view_counter += params.count",
"lang": "painless",
"params": {
"count": 1
}
},
"upsert": {
"moreInfo": {
"tags": [
"airline",
"flight",
"aeroplane",
"airplane"
],
"counter": 1,
"memo_1": ""
},
"view_counter": 1
}
}
GET /s_flights/_doc/1
flag scripted_upsert 的作用,如果数据不存在,则先使用upsert
创建文档,然后执行脚本
POST s_flights/_doc/1/_update
{
"scripted_upsert":true,
"script": {
"source": "ctx._source.view_counter += params.count",
"lang": "painless",
"params": {
"count": 1
}
},
"upsert": {
"moreInfo": {
"tags": [
"airline",
"flight",
"aeroplane",
"airplane"
],
"counter": 1,
"memo_1": ""
},
"view_counter": 1
}
}
GET /s_flights/_doc/1
通过scripts更新文档数据
POST s_flights/_doc/1/_update
{
"script": {
"source": "ctx._source.moreInfo.counter_status = ctx._source.moreInfo.counter === params.count ? 'isEnough' : params.count",
"params": {
"count": 10
},
"lang": "painless"
}
}
GET /s_flights/_doc/1?_source=moreInfo
查询数据
https://www.elastic.co/guide/en/elasticsearch/reference/current/term-level-queries.html
https://www.cnblogs.com/ghj1976/p/5293250.html
https://donlianli.iteye.com/blog/2094305
https://blog.csdn.net/weixin_43430036/article/details/83272018
轻量查询
获取所有数据(默认只查询10条出来)
GET /s_flights/_search?&_source=FlightNum,Origin,OriginCountry,Dest,DestCountry
获取id为1的数据
GET /s_flights/_doc/1?&_source=FlightNum,Origin,OriginCountry,Dest,DestCountry
获取数据请求头,返回的是状态码,以此判断数据是否存在
HEAD /s_flights/_doc/1
查询出发国家是US的数据
GET /s_flights/_search?q=OriginCountry:US&_source=FlightNum,Origin,OriginCountry,Dest,DestCountry
查询出发国家是US CN的数据
GET /s_flights/_search?q=OriginCountry:US+CN&_source=FlightNum,Origin,OriginCountry,Dest,DestCountry
查询mapping
GET /s_flights/_mapping/_doc
查看集群健康
GET /_cluster/health
通配符查询(wildcards query)
查询出发地国家名以C开头的
GET /s_flights/_search
{
"_source": [
"FlightNum",
"Origin",
"OriginCountry",
"Dest",
"DestCountry"
],
"query": {
"wildcard": {
"OriginCountry": {
"value": "C*"
}
}
}
}
查询航班编号值是 F开头 M9结尾的
GET /s_flights/_search
{
"_source": [
"FlightNum",
"Origin",
"OriginCountry",
"Dest",
"DestCountry"
],
"query": {
"wildcard": {
"FlightNum": {
"value": "F????M9"
}
}
}
}
短语查询(term query)
https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-term-query.html
查询 FlightNum 为 FFEVPM9的结果
GET /s_flights/_search
{
"_source": [
"FlightNum",
"Origin",
"OriginCountry",
"Dest",
"DestCountry"
],
"query": {
"term": {
"FlightNum": {
"value": "FFEVPM9"
}
}
}
}
多短语查询(terms query)
查询 FlightNum 为 6DJ0DZM ILXJVIF 的结果
GET /s_flights/_search
{
"_source": [
"FlightNum",
"Origin",
"OriginCountry",
"Dest",
"DestCountry"
],
"query": {
"terms": {
"FlightNum": ["6DJ0DZM","ILXJVIF"]
}
}
}
term set query
https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-terms-set-query.html
(范围查询)range query
查询飞行距离在100km(包含100km)到200km(包含200km)之间的结果
GET /s_flights/_search
{
"_source": [
"FlightNum",
"DistanceKilometers"
],
"query": {
"range": {
"DistanceKilometers": {
"gte": 100,
"lte": 200
}
}
}
}
exists query
prefix query
regexp query
fuzzy query
GET /s_flights/_search
{
"_source": [
"FlightNum",
"Origin"
],
"query": {
"fuzzy": {
"Origin": "bai"
}
}
}
type query
ids query
请求体查询(ad-hoc)
查询所有数据
GET /s_flights/_search
{
"_source": [
"FlightNum",
"Origin",
"OriginCountry",
"Dest",
"DestCountry"
],
"query": {
"match_all": {}
}
}
上面的等价于
GET /s_flights/_search?&_source=FlightNum,Origin,OriginCountry,Dest,DestCountry
匹配查询出发国家是US的数据
GET /s_flights/_search
{
"_source": [
"FlightNum",
"Origin",
"OriginCountry",
"Dest",
"DestCountry"
],
"query": {
"match": {
"OriginCountry": "US"
}
}
}
查询出发地包含Shanghai Tokyo的数据 (Origin是text类型,可以进行分词查询)
GET /s_flights/_search
{
"_source": [
"FlightNum",
"Origin",
"OriginCountry",
"Dest",
"DestCountry"
],
"query": {
"match": {
"Origin": "Shanghai Tokyo"
}
}
}
匹配查询出发地包含Shanghai Tokyo的数据 (Origin此处被当做是keyword类型,不可以进行分词查询,查询不出结果)
GET /s_flights/_search
{
"_source": [
"FlightNum",
"Origin",
"OriginCountry",
"Dest",
"DestCountry"
],
"query": {
"match": {
"Origin.keyword": "Shanghai Tokyo"
}
}
}
匹配查询出发地包含Shanghai Tokyo的数据 (Origin此处被当做是keyword类型,不可以进行分词查询),可以对整个词作为关键字进行查询,有结果
GET /s_flights/_search
{
"_source": [
"FlightNum",
"Origin",
"OriginCountry",
"Dest",
"DestCountry"
],
"query": {
"match": {
"Origin.keyword": "Shanghai Hongqiao International Airport"
}
}
}
匹配短语查询出发地包含Shanghai Hongqiao International的数据 (Origin是text类型,可以进行分词查询)
正常查询,查出一堆数据
GET /s_flights/_search
{
"_source": [
"FlightNum",
"Origin",
"OriginCountry",
"Dest",
"DestCountry"
],
"query": {
"match": {
"Origin": "Shanghai Hongqiao International"
}
}
}
匹配短语查询,只能查出一条
GET /s_flights/_search
{
"_source": [
"FlightNum",
"Origin",
"OriginCountry",
"Dest",
"DestCountry"
],
"query": {
"match_phrase": {
"Origin": "Shanghai Hongqiao International"
}
}
}
高亮查询,匹配短语查询出发地包含Shanghai Hongqiao International的数据 (Origin是text类型,可以进行分词查询),并对查询结果进行高亮(即对返回结果添加额外的标签)
GET /s_flights/_search
{
"_source": [
"FlightNum",
"Origin",
"OriginCountry",
"Dest",
"DestCountry"
],
"query": {
"match": {
"Origin": "Shanghai Hongqiao International"
}
}
, "highlight": {
"fields": {
"Origin":{}
}
}
}
自定义highlight 标签
GET /s_flights/_search
{
"_source": [
"FlightNum",
"Origin",
"OriginCountry",
"Dest",
"DestCountry"
],
"query": {
"match": {
"Origin": "Shanghai Hongqiao International"
}
}
, "highlight": {
"fields": {
"Origin":{
"pre_tags": "<span class='highlight '>",
"post_tags": "</span>"
}
}
}
}
高亮标签设置内部优先。
GET /s_flights/_search
{
"_source": [
"FlightNum",
"Origin",
"OriginCountry",
"Dest",
"DestCountry"
],
"query": {
"match": {
"Origin": "Shanghai Hongqiao International"
}
},
"highlight": {
"fields": {
"Origin": {
"pre_tags": "<span class='hightlight-origin'>",
"post_tags": "</span>"
}
},
"pre_tags": "<span class='hightlight'>",
"post_tags": "</span>"
}
}
查询出发国家是US,同时航班飞行最小分钟数小于100分钟的数据
GET /s_flights/_search
{
"_source": [
"FlightNum",
"Origin",
"OriginCountry",
"Dest",
"DestCountry"
],
"query": {
"bool": {
"must": {
"match": {
"OriginCountry": "US"
}
},
"filter": {
"range": {
"FlightTimeMin": {
"lt": 100
}
}
}
}
}
}
查询 OriginCountry
为USA和UK的航班记录
GET /s_flights/_search?q=OriginCountry:US+CA
GET /s_flights/_search
{
"query": {
"terms": {
"OriginCountry": ["US","CA"]
}
}
}
查询结果只显示字段 OriginCountry
和 DestCountry
GET /s_flights/_search
{
"_source": {
"includes": [ "OriginCountry", "DestCountry" ]
},
"query": {
"match_all": {}
}
}
GET /s_flights/_search
{
"_source":[ "OriginCountry", "DestCountry" ],
"query": {
"match_all": {}
}
}
查询结果只显示字段 OriginCountry
GET /s_flights/_search
{
"_source":"OriginCountry",
"query": {
"match_all": {}
}
}
不返回 _source
GET /s_flights/_search
{
"_source":false,
"query": {
"match_all": {}
}
}
查询出出发地是"US","NL", "JP" 的航班统计同时查询出每个出发地的不同目的地航班统计
GET /s_flights/_search
{
"_source":false,
"query": {
"terms": {
"OriginCountry": [
"US",
"NL",
"JP",
"CN"
]
}
},
"aggs": {
"all_origin": {
"terms": {
"field": "OriginCountry"
},
"aggs": {
"all_dest": {
"terms": {
"field": "DestCountry"
}
}
}
}
}
}
查询出出发地是"US","NL", "JP" 的航班统计同时查询出每个出发地的不同目的地航班统计,同时统计最小、最大和平均里程数
GET /s_flights/_search
{
"_source": "OriginCountry",
"query": {
"terms": {
"OriginCountry": [
"US",
"NL",
"JP",
"CN"
]
}
},
"aggs": {
"all_origin": {
"terms": {
"field": "OriginCountry"
},
"aggs": {
"all_dest": {
"terms": {
"field": "DestCountry"
}
},
"minDistanceKilometers": {
"min": {
"field": "DistanceKilometers"
}
},
"maxDistanceKilometers": {
"max": {
"field": "DistanceKilometers"
}
},
"avgDistanceKilometers": {
"avg": {
"field": "DistanceKilometers"
}
}
}
},
"minDistanceKilometers": {
"min": {
"field": "DistanceKilometers"
}
},
"maxDistanceKilometers": {
"max": {
"field": "DistanceKilometers"
}
},
"avgDistanceKilometers": {
"avg": {
"field": "DistanceKilometers"
}
}
}
}
查询出发地和目的地都是US的数据
GET /s_flights/_search
{
"query": {
"bool": {
"must": [
{
"match": {
"OriginCountry": "US"
}
},
{
"match": {
"DestCountry": "US"
}
}
]
}
}
}
查询无延机航班,时间范围在 2019-04-28
一天内,同时出发地国家为 "US","NL", "JP" 的航班统计同时查询出每个出发地的不同目的地航班统计
GET /s_flights/_search
{
"query": {
"bool": {
"must": [
{
"bool": {
"must": [
{
"match": {
"FlightDelayType": "No Delay"
}
}
]
}
},
{
"range": {
"timestamp": {
"gte": "2019-04-28 00:00:00",
"lte": "2019-04-29 00:00:00",
"time_zone": "+08:00",
"format": "yyyy-MM-dd HH:mm:ss"
}
}
},
{
"terms": {
"OriginCountry": [
"US",
"NL",
"JP"
]
}
}
]
}
},
"aggs": {
"all_origin": {
"terms": {
"field": "OriginCountry"
},
"aggs": {
"all_dest": {
"terms": {
"field": "DestCountry"
}
}
}
}
}
}
查询匹配天气,匹配 机场id ,最小飞行时间范围,不匹配 DestCountry I 开头 E结尾的
注意:官方数据这个里面如小时数是keyword类型,也就是string类型,所以会导致查询范围会出现有时候又数据,有时候没有数据,range应该针对number date。
GET /s_flights/_search
{
"query": {
"bool": {
"must": [
{
"bool": {
"should": [
{
"match_phrase": {
"DestWeather": "Clear"
}
},
{
"match_phrase": {
"DestWeather": "Sunny"
}
}
]
}
},
{
"terms": {
"OriginAirportID": [
"SHA",
"DWC"
]
}
},
{
"range": {
"FlightTimeMin": {
"gte": 100,
"lte": 900
}
}
}
],
"must_not": [
{
"wildcard": {
"DestCountry": "*E"
}
},
{
"wildcard": {
"DestCountry": {
"value": "I*"
}
}
}
]
}
}
}
_mget查询
获取id 为 1 2的数据
POST /s_flights/_doc/_mget
{
"ids":[1,2]
}
获取id 为 1 3的数据
POST /s_flights/_doc/_mget
{
"docs": [
{
"_id": 1
},
{
"_id": 3
}
]
}
官方教程4 分页
GET /_search
GET /_search?timeout=10ms
# 在所有的索引中搜索所有的类型
GET /_search
# 在 gb 索引中搜索所有的类型
GET /gb/_search
# 在 gb 和 us 索引中搜索所有的文档
GET /gb,us/_search
# 在任何以 g 或者 u 开头的索引中搜索所有的类型
GET /g*,u*/_search
#在 gb 索引中搜索 user 类型
/gb/user/_search
#在 gb 和 us 索引中搜索 user 和 tweet 类型
/gb,us/user,tweet/_search
#在所有的索引中搜索 user 和 tweet 类型
/_all/user,tweet/_search
GET /_search?size=5
GET /_search?size=5&from=5
GET /_search?size=5&from=10
和 SQL 使用 LIMIT 关键字返回单个 page 结果的方法相同,Elasticsearch 接受 from 和 size 参数:
# 显示应该返回的结果数量,默认是 10
size
# 显示应该跳过的初始结果数量,默认是 0
from
在分布式系统中深度分页
理解为什么深度分页是有问题的,我们可以假设在一个有 5 个主分片的索引中搜索。 当我们请求结果的第一页(结果从 1 到 10 ),每一个分片产生前 10 的结果,并且返回给 协调节点 ,协调节点对 50 个结果排序得到全部结果的前 10 个。
现在假设我们请求第 1000 页--结果从 10001 到 10010 。所有都以相同的方式工作除了每个分片不得不产生前10010个结果以外。 然后协调节点对全部 50050 个结果排序最后丢弃掉这些结果中的 50040 个结果。
可以看到,在分布式系统中,对结果排序的成本随分页的深度成指数上升。这就是 web 搜索引擎对任何查询都不要返回超过 1000 个结果的原因。
https://www.elastic.co/guide/cn/elasticsearch/guide/current/pagination.html
批量写入操作 _bulk
bulk api可以在单个请求中一次执行多个索引或者删除操作,使用这种方式可以极大的提升索引性能。
批量操作数据需要在一行
两行数据构成了一次操作,第一行是操作类型可以index,create,update,或者delete,第二行就是我们的可选的数据体,使用这种方式批量插入的时候,我们需要设置的它的Content-Type为application/json
。
针对不同的操作类型,第二行里面的可选的数据体是不一样的,如下:
(1)index 和 create 第二行是source数据体
(2)delete 没有第二行
(3)update 第二行可以是partial doc,upsert或者是script
我们可以将我们的操作直接写入到一个文本文件中,然后使用curl命令把它发送到服务端:
curl -s -H "Content-Type: application/x-ndjson" -XPOST localhost:9200/_bulk --data-binary "@requests"; echo
https://www.elastic.co/guide/cn/elasticsearch/guide/current/_Document_Metadata.html
https://www.cnblogs.com/wangzhuxing/p/9351245.html
https://blog.51cto.com/13630803/2162641?source=dra
https://elasticsearch.cn/question/5340
https://blog.csdn.net/jianjun200607/article/details/51262976/
https://blog.csdn.net/huwei2003/article/details/47004745
https://www.cnblogs.com/wulaiwei/p/9319821.html
https://www.cnblogs.com/wulaiwei/p/9319821.html
https://www.cnblogs.com/Angle-Louis/p/4218678.html
删索引
查看索引
curl http://192.168.0.163:9200/_cat/indices?v
删除索引,通配符形式
curl -XDELETE http://192.168.0.163:9200/索引*
索引起别名
curl -XPUT http://192.168.0.163:9200/索引/_alias/别名
查看别名
curl -XPUT http://192.168.0.163:9200/_cat/aliases?v
1.为啥在index里面加第二个type会报错?
ElasticSearch6.0以上的版本,不支持在同一个Index中拥有不同的Type。
同时官方还声明,将在7.0版本删除Type。
可以参考如下链接信息
- https://blog.csdn.net/EndTheme_Xin/article/details/85103375#commentBox
- https://www.elastic.co/guide/en/elasticsearch/reference/6.0/removal-of-types.html
2.为啥给数据设置为string类型报错?
ElasticSearch 5.0以后,string类型有重大变更,移除了string类型,string字段被拆分成两种新的数据类型: text用于全文搜索的,而keyword用于关键词搜索。
ElasticSearch字符串将默认被同时映射成text和keyword类型,将会自动创建下面的动态映射(dynamic mappings)
Text:会分词,然后进行索引 、支持模糊、精确查询、不支持聚合
keyword:不进行分词,直接索引、支持模糊、精确查询、支持聚合
可以参考如下链接信息
3.es启动报错max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144] - 每天进步一丶 - 博客园
https://www.cnblogs.com/yidiandhappy/p/7714489.html
elasticsearch启动时遇到的错误
问题翻译过来就是:elasticsearch用户拥有的内存权限太小,至少需要262144;
解决:
切换到root用户
执行命令:
sysctl -w vm.max_map_count=262144
查看结果:
sysctl -a|grep vm.max_map_count
显示:
vm.max_map_count = 262144
上述方法修改之后,如果重启虚拟机将失效,所以:
解决办法:
在/etc/sysctl.conf
文件最后添加一行
vm.max_map_count=262144
即可永久修改
4.es启动报错max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536] - cookzrk的专栏 - CSDN博客
https://blog.csdn.net/cookzrk/article/details/80179006
max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
切换到root用户
ulimit -Hn 查看硬限制
vim /etc/security/limits.conf
添加下面设置 hadoop是用户
hadoop soft nofile 65536
hadoop hard nofile 65536
退出用户重新登录,使配置生效
重新 ulimit -Hn 查看硬限制 会发现数值有4096改成65535
vim /etc/security/limits.d/90-nproc.conf
找到如下内容:
soft nproc 1024
修改为
soft nproc 2048
vi /etc/sysctl.conf
添加下面配置:
vm.max_map_count=655360
并执行命令:
sysctl -p
docker wsl 中的es配置
open powershell
wsl -d docker-desktop # wsl 连接到docker宿主
sysctl -w vm.max_map_count=282188
sysctl -p
5.Kibana优化过程(Optimize)过长或无法结束的解决方案
Kibana优化过程(Optimize)过长或无法结束的解决方案 - Elastic 中文社区
https://elasticsearch.cn/article/6188
发表评论