我正在开发一个计划将elasticsearch用作数据存储库的系统.我正在尝试选择开发我的应用程序的最佳方法,该应用程序可以索引和查询elasticsearch中的数据.我拥有的系统建立在Spring框架之上.
使用Spring-data-elasticsearch(https://github.com/spring-projects/spring-data-elasticsearch)是一个不错的选择吗?
或者使用elasticsearch核心库本身是一个不错的选择?
我需要处理嵌套数据(内部对象),但Spring-data-elasticsearch最近似乎没有操作.
我希望我能找到问题的解决方案.提前致谢.
java spring frameworks elasticsearch spring-data-elasticsearch
大家好,所有的弹性研究大师.
我有数百万个数据要由elasticsearch Java API索引.elasticsearch的集群节点数为3(1作为主节点+ 2节点).
我的代码片段如下.
Settings settings = ImmutableSettings.settingsBuilder()
.put("cluster.name", "MyClusterName").build();
TransportClient client = new TransportClient(settings);
String hostname = "myhost ip";
int port = 9300;
client.addTransportAddress(new InetSocketTransportAddress(hostname, port));
BulkRequestBuilder bulkBuilder = client.prepareBulk();
BufferedReader br = new BufferedReader(new InputStreamReader(new DataInputStream(new FileInputStream("my_file_path"))));
long bulkBuilderLength = 0;
String readLine = "";
String index = "my_index_name";
String type = "my_type_name";
String id = "";
while((readLine = br.readLine()) != null){
id = somefunction(readLine);
String json = new ObjectMapper().writeValueAsString(readLine);
bulkBuilder.add(client.prepareIndex(index, type, id)
.setSource(json));
bulkBuilderLength++;
if(bulkBuilderLength …Run Code Online (Sandbox Code Playgroud) 我开始使用Minitest在 Rails 上进行单元测试。
这是我对Product模型的第一个测试用例。
require "test_helper"
class ProductTest < ActiveSupport::TestCase
test "product price must be positive" do
product = Product.new(title: "My Book Title",
description: "yyy",
image_url: "zzz.jpg")
product.price = -1
assert product.invalid?, "negative price of a product must be invalid."
assert product.errors.has_key?(:price), "an invalid product must have an error"
product.price = 0
assert product.invalid?, "negative price of a product must be invalid."
assert product.errors.has_key?(:price), "an invalid product must have an error"
product.price = 1
assert product.valid?, …Run Code Online (Sandbox Code Playgroud) frameworks ×1
indexing ×1
java ×1
minitest ×1
performance ×1
ruby ×1
spring ×1
unit-testing ×1