ElasticSearch

ElasticSearch date range

不打扰是莪最后的温柔 提交于 2021-01-21 00:05:33
问题 I have the following query: { "query": { "query_string": { "query": "searchTerm", "default_operator": "AND" } }, "facets": { "counts": { "date_histogram": { "field": "firstdate", "interval": "hour" } } } and I would like to add a date range to it, so as to retrieve values for the field firstdate which are within a specific from/to interval. Any suggestions on how to do it? Many thanks! 回答1: you just need to add a range filter to your query: { "query":{ "filtered": { "query": { "query_string":

极简化ES数据同步,终于从繁琐重复的代码里脱身了

社会主义新天地 提交于 2021-01-20 21:02:51
一、背景 Elasticsearch是最近几年非常热门的分布式搜索和数据分析引擎,携程内部不仅使用ES实现了大规模的日志平台,也广泛使用ES实现了各个业务场景的搜索、推荐等功能。 本文聚焦在业务搜索的场景分享了我们在做数据同步方面的思考和实践,希望能对大家有所启发。 二、现状调研 数据同步是个很麻烦的事情,在各种论坛、分享中被大家反复讨论。 我们的需求大致包括全量、增量地从Hive、MySQL、Soa服务、Mq等不同类型的数据源获取数据,部分数据还需要进行一定的计算或者转换,然后近实时地同步到ES中,以被用户搜索到。 为了讨论方便,假定本文的场景是文章搜索的场景: 索引内容为文章,主要的信息保存在article表里; 每个文章关联了tag,保存在article_tag表里; tag表里的tagName也需要进入ES索引,以便使用标签名字搜索文章。 在以前同步这样的数据进入ES,单条文章的数据组装伪代码如下: List<Long> tagIds = articleTagDao.query("select tagId from article_tags where articleId=?", articleId); List<TagPojo> tags =tagDao.query("select id, name from tags whereid in (?)");

Why doesn't routing work with ElasticSearch Bulk API?

谁说我不能喝 提交于 2021-01-20 20:23:49
问题 I am setting a Bulk request to ElasticSearch and specifying the shard to route to. But when I run it, the documents get sent to different shards. Is this a bug in ElasticSEarch bulk? it works when I just index a single document. It works when I search. But not when I do a bulk import. To reproduce: curl -XPOST 'http://192.168.1.115:9200/_bulk?routing=a' -d ' { "index" : { "_index" : "articles", "_type" : "article", "_id" : "1" } } { "title" : "value1" } { "delete" : { "_index" : "articles", "

Why doesn't routing work with ElasticSearch Bulk API?

徘徊边缘 提交于 2021-01-20 20:20:30
问题 I am setting a Bulk request to ElasticSearch and specifying the shard to route to. But when I run it, the documents get sent to different shards. Is this a bug in ElasticSEarch bulk? it works when I just index a single document. It works when I search. But not when I do a bulk import. To reproduce: curl -XPOST 'http://192.168.1.115:9200/_bulk?routing=a' -d ' { "index" : { "_index" : "articles", "_type" : "article", "_id" : "1" } } { "title" : "value1" } { "delete" : { "_index" : "articles", "

Why doesn't routing work with ElasticSearch Bulk API?

亡梦爱人 提交于 2021-01-20 20:20:07
问题 I am setting a Bulk request to ElasticSearch and specifying the shard to route to. But when I run it, the documents get sent to different shards. Is this a bug in ElasticSEarch bulk? it works when I just index a single document. It works when I search. But not when I do a bulk import. To reproduce: curl -XPOST 'http://192.168.1.115:9200/_bulk?routing=a' -d ' { "index" : { "_index" : "articles", "_type" : "article", "_id" : "1" } } { "title" : "value1" } { "delete" : { "_index" : "articles", "

ElasticSearch in-memory for testing

流过昼夜 提交于 2021-01-20 17:52:09
问题 I would like to write some integration with ElasticSearch. For testing I would like to run in-memory ES. I found some information in documentation, but without example how to write those kind of test. Elasticsearch Reference [1.6] » Testing » Java Testing Framework » integration tests « unit tests Also I found following article, but it's out of data. Easy JUnit testing with Elastic Search I looking example how to start and run ES in-memory and access to it over REST API. 回答1: Based on the

重磅消息:Elastic 公司即将修改 ElasticSearch 的开源许可证

落花浮王杯 提交于 2021-01-19 15:59:58
1月15日, ElasticSearch 创始人、Elastic 公司 CEO Shay Banon 宣布,将把 Elasticsearch 和 Kibana 的 Apache 2.0-licensed 源码协议修改成 SSPL(Server Side Public License、服务器端公共许可证)和 Elastic License 双重协议!下面是 Shay Banon 修改 Elasticsearch 和 Kibana 开源协议的全文翻译。 注:下面的我们是指 Elastic 公司(或 Shay Banon) 我们正在将 ElasticSearch 和 Kibana 源代码的 Apache 2.0 许可证修改为服务器端公共许可(SSPL)和 Elastic License 双重许可,并且让用户可以选择申请哪个许可。此许可证变更确保了我们的社区和客户可以自由开放地代码进行使用、修改、重新分发和协作。它还通过限制云服务提供商提供 Elasticsearch和 Kibana 服务来保护我们在开发免费开放产品上的持续投资。这个修改将适用于这两个产品的所有维护分支,并将在即将发布的 7.11 版本之前发生。我们的发行版将继续使用过去三年用的 Elastic License。 源代码许可的这种改变对绝大多数免费使用我们默认发行版的社区用户、Elastic

SQL、NoSQL 到 NewSQL ,数据库到底选啥?

风格不统一 提交于 2021-01-19 11:08:39
先问一下,你们公司的主存储技术是什么?估计很多人答案都是 MySQL。 但,SQL 还够用吗? 那你再想一下,你当下的业务用 MySQL 做主存储还能支撑多久,如果业务量暴增,你能怎么做,愿意花多大价钱进行扩容? 如果遇到容量和性能问题就升级服务器,开发也太好做了。你要是只能想到这个答案,那今天要聊的这个话题——分布式数据库,对你来说跨度还挺大。 1分钟快速认识分布式数据库 分布式数据库其实就是多个节点的数据库共同形成一个全局数据库来提供服务,优点基本都在 以上对比里了, 访问速度更快,更强的可扩展性,支持更高的并发访问量。 各大互联网公司,甚至金融行业都开始使用分布式数据库,阿里巴巴有 OceanBase 风光无两,TiDB 在银行大受欢迎,各种云厂商相继发布重量级产品。 (2021 年数据大会上,阿里云发布了分布式数据库使用率统计图) 分布式数据库,是必然趋势 这个图展示了数据库技术这些年的技术探索,其实就是个逐渐“分布式”的过程。从 SQL 到 NewSQL 的技术探索,让分布式数据库能够满足两大核心要求: 完整的 ACID 支持,分布式事务和数据一致性保证; SQL 语法的完全兼容,对 SQL 业务的完整支持。 技术的完善性,加上学术与商业氛围浓厚, 分布式数据库已经是大势所趋。 有人会说,现在公司的数据库技术就挺成熟,有必要跟风追新吗? 公司做技术选型和架构设计

How to enforce a required field in elastic search?

|▌冷眼眸甩不掉的悲伤 提交于 2021-01-18 04:27:06
问题 I am building a cms using elastic search on the back end and my team has decided to use elastic search. I am new to it. I mostly use mongoose with mongodb from previous projects. In mongodb if I wrong assign a field or completely skip a required field mongodb throws an error. Is there a way to enforce required fields in elasticsearch? 回答1: There is not built in functionality, that will allow you to define required/mandatory fields in the mappings. Many will recommend you to do checks on the

Prometheus和Grafana监控Nacos

五迷三道 提交于 2021-01-17 16:53:08
Nacos 0.8.0版本完善了监控系统,支持通过暴露metrics数据接入第三方监控系统监控Nacos运行状态,目前支持prometheus、elastic search和influxdb,下面结合prometheus和grafana如何监控Nacos,官网 grafana监控页面 。与elastic search和influxdb结合可自己查找相关资料 Nacos集群暴露metrics数据 集群每个节点中修改配置application.properties文件,暴露metrics数据 cd /workspace/nacos/conf vim application.properties management.endpoints.web.exposure.include=* 看是否能访问到metrics数据 http://xx.xx.xx.xx:8848/nacos/actuator/prometheus 部署prometheus采集Nacos metrics数据 下载地址为 download prometheus 解压prometheus压缩包并安装 tar xvfz prometheus-*.tar.gz /workspace/ cd /workspace/prometheus 修改配置文件,注意格式缩进 vim prometheus.yml - job_name: