2015-11-16 85 views

回答

2

有人可以引導任何學習文檔/或任何鏈接請。

Elasticsearch: https://www.elastic.co/guide/en/elasticsearch/guide/current/index.html

春數據Elasticsearch: http://docs.spring.io/spring-data/elasticsearch/docs/current/reference/html/

我有我需要將其保存在ElasticSearch靜態JSON文件。

static static Settings settings = ImmutableSettings.settingsBuilder().put("cluster.name", "your_cluster_name").build(); 
static TransportClient transportClient = new TransportClient(settings); 
static Client client = transportClient.addTransportAddress(new InetSocketTransportAddress("192.xx.xx.xx", 9300)); 

client.prepareIndex("your_index_name", "your_type_name").setSource(jsonDoc).get(); 

我想知道我們如何能夠acheieve此使用的Spring Java。

//Create an interface like this. 
public interface YourClassRepository extends ElasticsearchRepository<YourClass, String> {} 

//In your service implementation class do this. 
@Autowired 
private YourClassRepository yourClassRepository; 

YourClass instance = new YourClass(); 
yourClassRepository.save(instance);