问题标签 [elasticsearch-api]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
4004 浏览

elasticsearch - 结合多个桶和聚合的 Elasticsearch

假设我们正在查看相当简单的数据——索引中的每个文档都有这样的结构:

我的问题基本上归结为我如何去做这样的事情:https ://www.elastic.co/guide/en/elasticsearch/guide/current/_combining_the_two.html 。具体来说,我正在尝试对Country和的所有组合执行相同的聚合(下面的查询) Addr。我当前的查询尝试如下。我聚合了 5 分钟的粒度(这是我的要求的一部分),到目前为止,我只能基于一个查询进行聚合。

这有效,但只是聚合与布尔过滤器匹配的所有文档(超过 5 分钟的存储桶)。相反,我想汇总和(超过 5 分钟的存储桶)的所有组合。CountryAddr

也就是说,对于所有具有 and 的文档,我想要一个聚合结果/指标(如in scriptbucket 中所示4),一个用于所有具有 and 的文档,"Country": "Germany"依此类推,对于所有s 和所有s。这可能在一个 Elasticsearch 请求中实现吗?我最好的选择是什么?"Addr": "security.web.com""Country": "United States""Addr": "security.web.com"AddrCountry

跟进

这是否也可以不跨越s 和s 的所有组合,而是跨越s 和s 的特定组合(我可能会在查询中列出)?还是我在一个请求中超出了 ES 的能力?AddrCountryAddrCountry

谢谢!

0 投票
1 回答
1106 浏览

python - Elasticsearch 滚动结束不返回任何内容

我正在使用适用于 Python 的 Elasticsearch 6.1 API,并尝试从数据库中的每个文档(303 958 个文档)中读取某个值。

索引(samplesCount)在 303 654 处结束,似乎 es.scroll 没有为剩余文档返回任何结果(大约 300,小于滚动大小)。

让我好奇的是,它以 303 654 结尾……我希望是一个整数(1000 的倍数)。

有任何想法吗 ?

非常感谢您提供任何有用的提示。

0 投票
1 回答
1340 浏览

php - Elasticsearch PHP:[文本]中 VALUE_STRING 的未知键

我正在使用Elasticsearch-PHP [6.0]
我有一个索引products,其中我有一个产品名称实现短语建议。

索引设置

查询参数

错误

谢谢你的帮助。

0 投票
1 回答
3372 浏览

elasticsearch - ElasticSearch Java HighLevelRestClient 连接被拒绝

我正在使用 Java HighLevelRestClient 连接到我在 AWS 上托管的 elasticsearch 实例。我可以通过邮递员和浏览器对 URL 发出请求,但是当我使用客户端库时,我会收到

java.net.ConnectException:连接被拒绝。

(我目前不需要任何身份验证,因为这是一个小型公共测试实例)。这是我的代码:

请让我知道如何解决这个问题...谢谢!

更新:这是我的 restClientBuilder 代码:

0 投票
1 回答
48 浏览

java - Elasticsearch:新 Java API 版本中的 IndicesQuery

我有两个索引。一个包含嵌套对象,另一个不包含。当我尝试对这两个索引执行查询时,出现以下错误:

基本上与此问题中描述的错误相同。那里的答案建议我应该使用indices查询。我能够QueryBuilders.indicesQuery(...)Java API 5.0 文档中找到方法。

但是,该indices查询在 5.0 中已弃用,说明:

在 5.0.0 中已弃用。改为搜索 _index 字段。

我找不到_index在当前 API (7.0) 中使用该字段的方法。如何从 Java 中使用它?

0 投票
1 回答
2766 浏览

elasticsearch - Elasticsearch - 使用分析器创建索引时出现非法参数异常

我正在使用 Elasticsearch 的 PHP API 和 Advanced REST Client (ARC) 来测试 ES API。当我尝试使用自定义分析器创建新索引时,出现此错误:

我尝试删除分析设置并成功创建索引。我还尝试从自定义分析器中删除过滤器,并且我已经重新安装了 2 次 ES。

必须使用该分析器创建索引

非常感谢!

0 投票
1 回答
3257 浏览

debugging - 如何可视化 Elasticsearch 执行的查询历史

您好 Elasticsearchers,

我是 Elasticsearch 的新手,我搜索了一个提议以允许我调试已执行的查询,因为我正在使用 elasticsearch PHP API,所以我想通过 Elasticsearch 可视化已执行查询的主体。

我尝试了该插件https://github.com/sonian/elasticsearch-jetty,但它看起来很旧,我正在使用 elasticseach 版本 6.7.1,所以我没有让它工作。

有什么建议么?谢谢。

0 投票
1 回答
69 浏览

elasticsearch - 如何在shopware的cron中使用elasticsearch的api?

我正在设置一个 cronjob 以在 shopware 中重新索引 Elasticsearch 索引,问题是在 cronjob 中执行“php bin/console sw:es:index:populate”。请帮帮我。

我试图为 IndexPopulateCommand 添加服务但是我无法从 cron 访问它

0 投票
1 回答
864 浏览

maven - Transitive Dependency: Using Elasticsearch Rest High Client problem in AEM

I am trying to use Java High Level Rest Client in Adobe Experience Manager to finish project of comparison between Lucene, Solr and Elasticsearch search engines.

I am having some problems with elasticsearh implementation. Here is the code:

  • Dependency in the parent pom.xml (the same is defined in core pom.xml)

    /li>
  • The only line of code that I am using that is from dependencies above

    /li>

protocol = "http", server = "localhost", port = 9200, secondPort = 9201

  • Error

enter image description here

  • Dependencies from IntelliJ

enter image description here

I know that there is usually problem with dependencies versions, but all are 7.4.0 in this case. Also elasticsearch 7.4.0v is running locally on 3 nodes.

This project is done on We.Retail project so it is easy to replicate. Also all the code with this error is available here: https://github.com/tadijam64/search-engines-comparison-on-we-retail/tree/elasticsearch-integration AEM 6.4v.

Any info or idea is appreciated.

UPDATE I tried with adding the following to embed these dependencies externally since they are not OSGi dependencies:

The error remains. I also tried adding it to the "export-package", but nothing helps.

And by Elasticsearch documentation, all I need to use Elasticsearch is

but then NoClassDefFoundErrors occurs. It seems like a problem with transitive dependencies maybe. Not sure, but any idea is appreciated.

Some other suggestions can be found here: https://forums.adobe.com/thread/2653586

I have also tried adding it's transitive dependencies like org.elasticsearch and org.elasticsearch.client, but it does not work. The same error, just other class.

AEM version 6.4, Java version: jdk1.8.0_191.jdk

0 投票
2 回答
1492 浏览

java - 如何使用 Java 中的 API 更新(版本 5)更新 ElasticSearch 中的哈希图数据?

我正在尝试使用以下代码更新 Elastic Search Server 中的数据。

1)我使用以下方法在弹性搜索中插入数据。

当我使用该键查询弹性搜索时,得到以下结果:

插入数据(HashMap)后,它被成功插入到搜索中。

2)尝试更新相同的。

之后,当我尝试使用以下代码更新 case_extra 时。搜索查询显示现有值。

结果:

根据上述结果,没有从 case_extra 中删除键“Two”。

我需要帮助才能在 elasticsearch 中使用 Api Update,我尝试了上面的代码,问题是从 case_extra 中删除的 HashMap 的第二个值。

提前致谢。

更新

这是我尝试过的代码。

在更新请求之前,文档如下所示:

更新请求代码与 Garvit Khamesra 在他的回答中给出的相同:

运行上述代码后,我收到的错误如下:

我使用的依赖项如下: