
ES
文章平均质量分 65
CLA1989
这个作者很懒,什么都没留下…
展开
-
ES-16聚合
1.汽车经销商可能会想知道哪个颜色的汽车销量最好,用聚合可以轻易得到结果,用 terms 桶操作:GET /cars/transactions/_search{ "size" : 0, "aggs" : { "popular_colors" : { "terms" : { "field" : "color" } } }}让我们继续为汽车的例子加入 average...原创 2021-09-27 17:52:54 · 291 阅读 · 0 评论 -
ES15-深入查询
1.多字符串查询:如果我们知道 War and Peace 是标题,Leo Tolstoy 是作者,很容易就能把两个条件用 match 语句表示,并将它们用 bool 查询 组合起来:GET /_search{ "query": { "bool": { "should": [ { "match": { "title": "War and Peace" }}, { "match": { "author": "Leo Tolstoy" }}...原创 2021-09-22 15:09:05 · 569 阅读 · 0 评论 -
ES14-组合查询
1.GET /my_index/my_type/_search{ "query": { "bool": { "must": { "match": { "title": "quick" }}, "must_not": { "match": { "title": "lazy" }}, "should": [ { "match": { "title": "brown" }}, { "...原创 2021-09-17 16:02:50 · 379 阅读 · 0 评论 -
ES3-匹配查询
1.单个词查询:用 match 查询搜索全文字段中的单个词GET /my_index/my_type/_search{ "query": { "match": { "title": "QUICK!" } }}2.多词查询:我们一次只能搜索一个词,那么全文搜索就会不太灵活,幸运的是 match 查询让多词查询变得简单GET /my_index/my_type/_search{ "query": { ...原创 2021-09-17 15:07:13 · 910 阅读 · 0 评论 -
ES12-结构化搜索
1.term 查询, 可以用它处理数字(numbers)、布尔值(Booleans)、日期(dates)以及文本(text)例如:term 查询会查找我们指定的精确值sql: SELECT document FROM products WHERE price = 20GET /my_store/products/_search{ "query" : { "constant_score" : { "filter" : { ...原创 2021-09-17 11:04:47 · 153 阅读 · 0 评论 -
ES11-索引管理
1.禁用 _source 字段PUT /my_index{ "mappings": { "my_type": { "_source": { "enabled": false } } }}2.在一个搜索请求里,你可以通过在请求体中指定 _source 参数,来达到只获取特定的字段的效果:GET /_search{ "query": { "match_all...原创 2021-09-17 09:43:35 · 862 阅读 · 0 评论 -
ES9-游标查询scroll
1.scroll 查询 可以用来对 Elasticsearch 有效地执行大批量的文档查询,而又不用付出深度分页那种代价。启用游标查询可以通过在查询的时候设置参数 scroll 的值为我们期望的游标查询的过期时间。游标查询的过期时间会在每次做查询的时候刷新,所以这个时间只需要足够处理当前批的结果就可以了,而不是处理查询结果的所有文档的所需时间。 这个过期时间的参数很重要,因为保持这个游标查询窗口需要消耗资源,所以我们期望如果不再需要维护这种资源就该早点儿释放掉。 设置这个超时能够让 Elasticse.原创 2021-09-15 18:14:20 · 553 阅读 · 0 评论 -
ES8-排序
1.为了按照相关性来排序,需要将相关性表示为一个数值。在 Elasticsearch 中, 相关性得分 由一个浮点数进行表示,并在搜索结果中通过 _score 参数返回, 默认排序是 _score 降序。有时,相关性评分对你来说并没有意义。例如,下面的查询返回所有 user_id 字段包含 1 的结果。GET /_search{ "query" : { "bool" : { "filter" : { "term" : {...原创 2021-09-15 14:56:15 · 656 阅读 · 0 评论 -
ES7-验证查询
1.GET /gb/tweet/_validate/query{ "query": { "tweet" : { "match" : "really powerful" } }}注:以上 validate 请求的应答告诉我们这个查询是不合法的{ "valid" : false, "_shards" : { "total" : 1, "successful" : 1, "failed" :...原创 2021-09-13 15:50:51 · 345 阅读 · 0 评论 -
ES6-重要的查询,组合查询
1.使用 match 查询语句 来查询 tweet 字段中包含 elasticsearch 的 tweetGET /_search{ "query": { "match": { "tweet": "elasticsearch" } }}2.找出信件正文包含 business opportunity 的星标邮件,或者在收件箱正文包含 business opportunity 的非垃圾邮件3.match_all 查询:matc...原创 2021-09-13 15:44:30 · 641 阅读 · 0 评论 -
ES5-请求体查询
1.空查询GET /_search{}或者GET /_search{ "query": { "match_all": {} }}2.在一个、多个或者 _all 索引库(indices)和一个、多个或者所有types中查询GET /index_2014*/type1,type2/_search{}3.分页GET /_search{ "from": 30, "size": 10}或者POST /_search{ "from...原创 2021-09-13 11:02:45 · 304 阅读 · 0 评论 -
ES4-映射
25.请求 gb 索引中 tweet 类型的映射(或模式定义)GET /gb/_mapping/tweet26.测试分析器GET /_analyze{ "analyzer": "standard", "text": "Text to analyze"}27.查看映射GET /gb/_mapping/tweet28.删除索引DELETE /gb29.创建新索引,指定 tweet 域使用 english 分析器PUT /gb{ "mappings": { ...原创 2021-09-13 10:17:24 · 134 阅读 · 0 评论 -
ES高级查询3
1.多索引,多类型/_search在所有的索引中搜索所有的类型/gb/_search在 gb 索引中搜索所有的类型/gb,us/_search在 gb 和 us 索引中搜索所有的文档/g*,u*/_search在任何以 g 或者 u 开头的索引中搜索所有的类型/gb/user/_search在 gb 索引中搜索 user 类型/gb,us/user,tweet/_search在 gb 和 us 索引中搜索 user 和 tweet 类型/_all/user,tweet/_searc原创 2021-09-10 11:28:48 · 259 阅读 · 0 评论 -
ES基础2-增删改
1.添加自定义id的文档PUT /website/blog/123{ "title": "My first blog entry", "text": "Just trying this out...", "date": "2014/01/01"}2.Elasticsearch 可以帮我们自动生成 IDPOST /website/blog/{ "title": "My second blog entry", "text": "Still trying this out.....原创 2021-09-09 16:58:04 · 555 阅读 · 0 评论 -
ES基础入门1
1.新增数据PUT /megacorp/employee/1{ "first_name" : "John", "last_name" : "Smith", "age" : 25, "about" : "I love to go rock climbing", "interests": [ "sports", "music" ]}2.查询id为1的数据GET /megacorp/employee/13.查询所有数据GET /meg...原创 2021-09-09 15:05:47 · 332 阅读 · 0 评论