我有以下类型的文件:
[{"msg":"hello", date: "some-date"},{"msg":"hi!", date: "some-date"}, ...
Run Code Online (Sandbox Code Playgroud)
我想按星期几计算文档数。例如,周一发送了 x 条消息,周二发送了 y 条消息,依此类推。
我已经将 date_histogram 与聚合一起使用,但它每天都会返回文档。它确实返回了我的一天,但是说“星期三,22”和“星期三,29”作为单独的聚合文档返回。
这与Elasticsearch有点相关- 按星期几和小时分组,但该问题没有答案,所以我重新发布。根据那里的建议,它要求我对 key_as_string 进行术语聚合,但我需要为每个对象添加 doc_count,而不仅仅是计算术语。我也不知道如何在嵌套聚合中使用 key_as_string。
这是我尝试过的:
"aggs" : {
"posts_over_days" : {
"date_histogram" : {
"field" : "created_time",
"interval": "day",
"format": "E"
}
}
Run Code Online (Sandbox Code Playgroud) nosql elasticsearch elasticsearch-plugin pyelasticsearch spring-data-elasticsearch
我开始使用Elasticsearch 2.0.我有一个Elasticsearch插件但无法在新版本2.0上安装它.它给出了一个错误:
/Downloads/elasticsearch-2.0.0/bin$ ./plugin install file:///home/fatih/Downloads/myftptest/zemberekplugin.zip
-> Installing from file:/home/fatih/Downloads/myftptest/zemberekplugin.zip...
Trying file:/home/fatih/Downloads/myftptest/zemberekplugin.zip ...
Downloading .......DONE
Verifying file:/home/fatih/Downloads/myftptest/zemberekplugin.zip checksums if available ...
NOTE: Unable to verify checksum for downloaded plugin (unable to find .sha1 or .md5 file to verify)
ERROR: Could not find plugin descriptor 'plugin-descriptor.properties' in plugin zip
Run Code Online (Sandbox Code Playgroud)
我该如何解决?
我对编程很陌生,所以我的问题可能很愚蠢/容易做,但是:我需要根据用户输入在elasticsearch中创建多个过滤器
我的查询正文:
body = {
"query": {
"filtered": {
"filter": {
"bool": {
"must": [
{"term": {name1: value1}},
{"term": {name2: value2}},
{"term": {name3: value3}},
]
}
}
}
},
}
Run Code Online (Sandbox Code Playgroud)
它工作正常,但我需要有这些过滤器的动态数量
我尝试将查询构建到字符串中,然后在其中添加过滤器,但 es 不允许这样做,例如:
l = []
for i_type, name in convert.items():
string = '{"term": {"' + i_type + '":"' + name + '"}},'
l.append(string)
i_query = ''.join(l)
Run Code Online (Sandbox Code Playgroud)
当我在查询结构中使用列表/字符串时,我从服务器收到 404 错误
是否可以添加动态数量的过滤器?
我正在使用 Elasticsearch 2.3.3 并尝试制作现有索引的精确副本。(使用与 Elasticsearch 安装捆绑在一起的 reindex 插件)
问题在于复制了数据,但遗漏了映射和分析器等设置。
制作现有索引(包括其所有设置)的精确副本的最佳方法是什么?
我的主要目标是创建一个副本,更改该副本,并且只有在一切顺利的情况下才将别名切换到该副本。(零停机备份和恢复)
嗨,我可以用 DateRangeQuery 数组填充 QueryContainer,如下所示
if (!string.IsNullOrEmpty((item.marriage_date)))
{
DateRangeQuery query = new DateRangeQuery();
query.Field = "marriages.marriage_date";
query.Name = item.marriage_date;
query.GreaterThanOrEqualTo = item.marriage_date;
query.LessThanOrEqualTo = item.marriage_date;
marriageDateQuerys &= query;
}
Run Code Online (Sandbox Code Playgroud)
但是当我使用 QueryContainer 使用 MatchQuery/TermQuery 来填充数据时,它并没有发生。
QueryContainer marriageSpouseFirstNameQuerys = null;
if (!string.IsNullOrEmpty((item.spouse_first_name)))
{
MatchQuery query = new MatchQuery();
query.Field = "marriages.spouse_first_name";
query.Name = item.spouse_first_name;
marriageSpouseFirstNameQuerys &= query;
}
Run Code Online (Sandbox Code Playgroud)
查询对象是在最后一个 if 条件下创建的,但 marionSpouseFirstNameQuerys 没有填充相同的条件。我什至试过marriageSpouseFirstNameQuerys += query; 但没有任何成功
如何将 ES (v 5.x) 索引从一台服务器复制到另一台服务器。我没有权限在这台机器上安装任何软件。有没有更好的解决方案来复制索引?备份和恢复会起作用吗?请分享您的建议
我使用的是最新版本的elasticsearch-php以及最新版本的MongoDB和ElasticSearch.
我需要在可以包含一个或多个值的多个字段上进行搜索.例:
country_code应为NL,BE或DE,类别应包含AA01,BB01,CC02或ZZ11
我以为我会按照以下方式解决它(PHP):
$countries = array(“NL”, “BE”, “DE”);
$category = array(“AA01”, “BB01”, “CC02”, “ZZ11”);
$searchParams['body']['query']['bool']['must']['terms']['country'] = $countries;
$searchParams['body']['query']['bool']['must']['terms']['categories'] = $category;
$searchParams['body']['query']['bool']['must']['terms']['minimum_should_match'] = 1;
Run Code Online (Sandbox Code Playgroud)
但结果甚至没有接近我希望得到的数据.
有时$ States和/或$ category只能有一个元素.
我已经使用ElasticSearch的_plugin / head接口成功创建了查询。该查询旨在返回特定位置的特定设备的最新时间戳。该查询如下所示:
{
"query":{
"bool":{
"must":[
{
"term":{
"deviceevent.location.id":"1"
}
},
{
"term":{
"deviceevent.deviceId":"AHE1LDD01"
}
}
]
}
},
"from":0,
"size":1,
"sort":{
"timestamp":{
"order":"desc"
}
}
}
Run Code Online (Sandbox Code Playgroud)
上面的查询按预期工作。现在使用Spring-Boot和Spring-Data-ElasticSearch,我定义了自己的ElasticSearchRepository外观,如下所示:
package com.repository.elasticsearch;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.elasticsearch.annotations.Query;
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
import com.domain.DeviceEvent;
public interface DeviceEventRepository extends ElasticsearchRepository<DeviceEvent, String>
{
@Query("{\"bool\":{\"must\":[{\"term\":{\"deviceevent.location.id\": \"?0\"}},{\"term\":{\"deviceevent.deviceId\": \"?1\"}}]}},\"from\": 0,\"size\": 1,\"sort\":{\"timestamp\":{\"order\":\"desc\"}}")
DeviceEvent findLatestCheckInAtLocation(Long locationId, String deviceId);
}
Run Code Online (Sandbox Code Playgroud)
上面的代码之所以中断,主要是因为我希望它返回一个DeviceEvent,但实际上它返回的是带有count = 10(默认页面大小)的设备事件。似乎时间戳也没有按降序对结果进行排序。好像查询的size和order部分没有被拾取。
我在这里做错了什么?
elasticsearch elasticsearch-plugin spring-boot spring-data-elasticsearch
我正在编写一个elasticsearch插件,它依赖于从磁盘上的文件中读取数据.当我尝试在我的代码中访问此文件时,我得到以下异常.
Caused by: java.security.AccessControlException: access denied ("java.io.FilePermission" "patient_similarity/codes.txt" "read")
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:472)
at java.security.AccessController.checkPermission(AccessController.java:884)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
at java.lang.SecurityManager.checkRead(SecurityManager.java:888)
at java.io.FileInputStream.<init>(FileInputStream.java:127)
at org.gatech.lucene.search.store.DotProductStore.<init>(DotProductStore.java:22)
at org.gatech.lucene.search.store.DotProductStore.newInstance(DotProductStore.java:71)
at org.gatech.elasticsearch.CommonsPlugin.onModule(CommonsPlugin.java:39)
Run Code Online (Sandbox Code Playgroud)
有没有推荐的方法来访问elasticsearch插件中的文件?有没有快速的解决方法来访问我的插件中的文件?
java accesscontrolexception elasticsearch elasticsearch-plugin
我根据安装指南设置了Elasticsearch,Kibana和X-pack,并确保它按预期工作.现在我想使用X-Pack中的Watchers发送Kibana报告.我已经按照本教程设置了安全报告,但在将watcher truststore添加到elasticsarch.yml之后,当我尝试启动弹性时,我收到此错误消息:
[2016-11-22T12:19:57,111][INFO ][o.e.e.NodeEnvironment ] [CBeNcdh] using [1] data paths, mounts [[OS (c:)]], net usable_space [72.3gb], net total_space [223.5gb], spins? [unknown], types [NTFS]
[2016-11-22T12:19:57,115][INFO ][o.e.e.NodeEnvironment ] [CBeNcdh] heap size [1.9gb], compressed ordinary object pointers [true]
[2016-11-22T12:19:57,354][INFO ][o.e.n.Node ] [CBeNcdh] node name [CBeNcdh] derived from node ID; set [node.name] to override
[2016-11-22T12:19:57,358][INFO ][o.e.n.Node ] [CBeNcdh] version[5.0.1], pid[15948], build[080bb47/2016-11-11T22:08:49.812Z], OS[Windows 10/10.0/amd64], JVM[Oracle Corporation/Java HotSpot(TM) 64-Bit Server VM/1.8.0_111/25.111-b14]
[2016-11-22T12:19:58,618][ERROR][o.e.b.Bootstrap ] Exception
org.elasticsearch.ElasticsearchException: Failed to load plugin class [org.elasticsearch.xpack.XPackPlugin]
at org.elasticsearch.plugins.PluginsService.loadPlugin(PluginsService.java:462) ~[elasticsearch-5.0.1.jar:5.0.1] …Run Code Online (Sandbox Code Playgroud)