Tag: elasticsearch

使用Elastic Search 5.5.0获得最佳性能时如何正确关闭原始RestClient?

我使用Spring Boot 1.5.4.RELEASE Microservice使用ElasticSearch提供的低级Rest Client连接到ElasticSearch 5.5.0实例。 的pom.xml org.springframework.boot spring-boot-starter-parent 1.5.4.RELEASE org.springframework.boot spring-boot-starter-web org.springframework.boot spring-boot-starter-test test org.elasticsearch elasticsearch 5.5.0 org.elasticsearch.client transport 5.5.0 org.apache.commons commons-lang3 3.6 com.fasterxml.jackson.core jackson-core 2.8.9 com.fasterxml.jackson.core jackson-databind 2.8.9 com.fasterxml.jackson.core jackson-annotations 2.8.9 log4j log4j 1.2.17 junit junit 4.11 test io.springfox springfox-swagger2 2.6.1 compile io.springfox springfox-swagger-ui 2.6.1 compile 一切都设置正确,但在一堆点击后,客户端应用程序报告HTTP 500错误,这是日志文件中出现的: java.io.IOException: Too many open files […]

使用Java API更新ElasticSearch索引中的嵌套字段

我在弹性搜索上使用Java API进行CRUD操作。 我有一个带嵌套字段的类型,我想更新这个字段。 这是我的类型映射: “enduser”: { “properties”: { “location”: { “type”: “nested”, “properties”:{ “point”:{“type”:”geo_point”} } } } } 当然我的最终用户类型将有其他参数。 现在我想在嵌套字段中添加此文档: “location”:{ “name”: “London”, “point”: “44.5, 5.2” } 我在文档中搜索如何更新嵌套文档,但我找不到任何东西。 例如,我在字符串中有前面的JSON obect(让我们调用这个字符串json)。 我尝试了以下代码,但似乎无法正常工作: params.put(“location”, json); client.prepareUpdate(index, ElasticSearchConstants.TYPE_END_USER,id).setScript(“ctx._source.location = location”).setScriptParams(params).execute().actionGet(); 我有来自elasticsearch的解析错误。 谁知道我做错了什么?

Spring Data Elasticsearch:具有相同文档的多索引

我正在使用spring-data-elasticsearch,一开始一切正常。 @Document( type = “products”, indexName = “empty” ) public class Product { … } public interface ProductRepository extends ElasticsearchRepository { … } 在我的模型中,我可以搜索产品。 @Autowired private ProductRepository repository; … repository.findByIdentifier( “xxx” ).getCategory() ); 所以,我的问题是 – 我在不同的索引中使用相同的Elasticsearch类型,我想对所有查询使用相同的文档。 我可以通过池处理更多连接 – 但我不知道如何实现这一点。 我希望有这样的东西: ProductRepository customerRepo = ElasticsearchPool.getRepoByCustomer(“abc”, ProductRepository.class); repository.findByIdentifier( “xxx” ).getCategory(); 是否可以在运行时使用不同的索引创建存储库? 非常感谢Marcel

在弹性搜索中使用service install命令“JAVA_HOME指向无效的Java安装问题”

我想在我的PHP应用程序中使用弹性搜索。 运行service install命令后 ,我得到了错误。 C:\elasticsearch-0.90.10\bin>service install JAVA_HOME points to an invalid Java installation (no java.exe found in “C:\Progr am Files (x86)\Java\jdk1.7.0_25\bin”). Existing…

从java开始弹性搜索实例?

我想管理从Java开始和停止elasticsearch。 有没有简单/好的方法来做到这一点? 我们正在尝试在我们的产品中部署ElasticSearch,并且我们希望在我们自己的产品中维护客户机器上的ElasticSearch实例,现在每件事都依赖于从es.bat或其他东西启动ElasticSearch实例。 顺便说一句,任何人都可以给我一个如何模拟测试围绕Jest API for ElasticSearch的一些代码的例子,所以我可以unit testing调用ElasticSearch而不需要启动ElasticSearch实例的东西吗?

elasticsearch – 没有为注册的查询]

我试图从我的测试中向ES发送请求。 我将映射和插入的文档应用于同一测试中名为’gccount_test’的ES索引 。 我在一个名为member的文件中维护了一个非常简单的查询,我想测试它。 { “query” : { “match_all” : {} } } 我的测试方法是 public void testMemberQuery(){ final Charset CHARSET = StandardCharsets.UTF_8 //load query byte[] bytes = Files.readAllBytes(Paths.get(MEMBER_QUERY_PATH)) String query = CHARSET.decode(ByteBuffer.wrap(bytes)).toString() println “QUERY => ${query}” SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder() searchSourceBuilder.query(query) SearchRequestBuilder searchRequestBuilder = client.prepareSearch(INDEX_NAME) //ClusterAdminClient adminClient = client.admin().cluster() //searchRequestBuilder.setTypes(Constants.ESTYPE_MEMBER) //println “CLUSTER => ${adminClient}” […]

GET HTTP请求有效负载

我正在设计一个API,我想知道在GET请求上发送JSON有效负载是否合适? 在这个其他问题的HTTP请求方法的有效载荷 ,我们可以根据这个链接找到: 头部 – 没有定义的身体语义。 GET – 没有定义的正文语义。 PUT – 身体支持。 POST – 支持身体。 DELETE – 没有定义的正文语义。 TRACE – 身体不受支持。 选项 – 支持身体但没有语义(可能在将来)。 这是否意味着我不应该发送带有效负载的GET请求? 这样做有风险吗? 就像让一些HTTP客户端库无法发送这样的有效载荷一样? 或者我的Java API代码无法在某些应用程序服务器上移植? 还要别的吗? 我发现ElasticSearch在GET请求上使用了这样的有效负载: $ curl -XGET ‘http://localhost:9200/twitter/tweet/_search?routing=kimchy’ -d ‘{ “query”: { “filtered” : { “query” : { “query_string” : { “query” : “some query string here” } […]

读取Elasticsearch插件中的文件

我正在编写一个elasticsearch插件,它依赖于从磁盘上的文件中读取数据。 当我尝试在我的代码中访问此文件时,我得到以下exception。 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.(FileInputStream.java:127) at org.gatech.lucene.search.store.DotProductStore.(DotProductStore.java:22) at org.gatech.lucene.search.store.DotProductStore.newInstance(DotProductStore.java:71) at org.gatech.elasticsearch.CommonsPlugin.onModule(CommonsPlugin.java:39) 有没有推荐的方法来访问elasticsearch插件中的文件? 有没有快速的解决方法来访问我的插件中的文件?

elasticsearch java批量大小

我想使用java的elasticsearch bulk api,并想知道如何设置批量大小。 目前我正在使用它: BulkRequestBuilder bulkRequest = getClient().prepareBulk(); while(hasMore) { bulkRequest.add(getClient().prepareIndex(indexName, indexType, artist.getDocId()).setSource(json)); hasMore = checkHasMore(); } BulkResponse bResp = bulkRequest.execute().actionGet(); //To check failures log.info(“Has failures? {}”, bResp.hasFailures()); 知道如何设置批量/批量大小吗?

无法使用Java API连接到ElasticSearch服务器

我正在尝试使用Java API连接到ElasticSearch服务器。 我使用elasticsearch服务来启动/停止和弹性搜索头来可视化集群。 群集/节点处于活动状态,REST API在9200上通过curl工作正常。我几乎阅读了关于此主题的所有post,但我无法使其工作,下面是我的详细信息: 我尝试了所有这些: 在TransportClient中使用localhost,devhost1,127.0.0.1或网络上的实际IP 取消注释config.yaml中的IP属性并放入127.0.0.1(服务器) 检查端口9300是否可用,它是。 … 9200 / _cluster /节点 { “ok”: true, “cluster_name”: “test”, “nodes”: { “NLVBbJpJTZWefeI2kQt3Tg”: { “name”: “inventory_management”, “transport_address”: “inet[/127.0.0.1:9300]”, “hostname”: “devhost1”, “version”: “0.90.5”, “http_address”: “inet[/127.0.0.1:9200]” } } } … 9200 / _cluster /健康?漂亮=真 { “cluster_name” : “test”, “status” : “green”, “timed_out” : false, “number_of_nodes” : 1, “number_of_data_nodes” […]