🎉 init
This commit is contained in:
parent
b8729a4e37
commit
d0690642b1
11
pom.xml
11
pom.xml
@ -28,13 +28,12 @@
|
||||
<dependency>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-elasticsearch</artifactId>
|
||||
<version>3.0.14.RELEASE</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.elasticsearch.plugin</groupId>
|
||||
<artifactId>transport-netty4-client</artifactId>
|
||||
<version>5.6.16</version>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.elasticsearch.plugin</groupId>-->
|
||||
<!-- <artifactId>transport-netty4-client</artifactId>-->
|
||||
<!-- <version>5.6.16</version>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- <!–需要引入transport-netty3-client,否则会启动报错–>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.elasticsearch.plugin</groupId>-->
|
||||
|
@ -1,11 +1,25 @@
|
||||
package com.darkness.controller;
|
||||
|
||||
import com.darkness.common.PublicConst;
|
||||
import com.darkness.pojo.dto.es.PopulationElasticsearchDto;
|
||||
import com.darkness.repository.PopulationElasticsearchRepository;
|
||||
import com.darkness.service.DemoService;
|
||||
import org.elasticsearch.index.query.BoolQueryBuilder;
|
||||
import org.elasticsearch.index.query.QueryBuilders;
|
||||
import org.elasticsearch.search.sort.FieldSortBuilder;
|
||||
import org.elasticsearch.search.sort.SortBuilders;
|
||||
import org.elasticsearch.search.sort.SortOrder;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.elasticsearch.core.query.NativeSearchQuery;
|
||||
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("d")
|
||||
@ -13,12 +27,30 @@ public class DemoController {
|
||||
|
||||
@Resource
|
||||
private DemoService service;
|
||||
@Resource
|
||||
private PopulationElasticsearchRepository repository;
|
||||
|
||||
@GetMapping("d")
|
||||
public void demo(){
|
||||
service.insertDemoUser();
|
||||
System.out.println(service.selectDemoUser());
|
||||
service.insertDemoUnit();
|
||||
System.out.println(service.selectDemoUnit());
|
||||
// service.insertDemoUser();
|
||||
// System.out.println(service.selectDemoUser());
|
||||
// service.insertDemoUnit();
|
||||
// System.out.println(service.selectDemoUnit());
|
||||
|
||||
// PopulationElasticsearchDto pop = new PopulationElasticsearchDto();
|
||||
// pop.setId(120100L);
|
||||
// pop.setCertificateNo("123123");
|
||||
// pop.setDocumentType(1);
|
||||
// repository.save(pop);
|
||||
//
|
||||
// PopulationElasticsearchDto pop1 = new PopulationElasticsearchDto();
|
||||
// pop1.setId(120101L);
|
||||
// pop1.setCertificateNo("456456");
|
||||
// pop1.setDocumentType(1);
|
||||
// repository.save(pop1);
|
||||
|
||||
Page<PopulationElasticsearchDto> search = repository.findAll(Pageable.unpaged());
|
||||
List<PopulationElasticsearchDto> list = search.getContent();
|
||||
System.out.println(list);
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ import java.sql.Timestamp;
|
||||
|
||||
|
||||
@Data
|
||||
@Document(indexName = PublicConst.E_ACTUAL_POPULATION_INDEX_NAME,type = PublicConst.ES_INDEX_TYPE
|
||||
@Document(indexName = PublicConst.E_ACTUAL_POPULATION_INDEX_NAME
|
||||
,shards = PublicConst.ES_SHARDS, replicas = PublicConst.ES_REPLICAS, createIndex = false)
|
||||
@Setting(settingPath = PublicConst.ES_SETTING_SETTINGPATH)
|
||||
public class PopulationElasticsearchDto {
|
||||
|
@ -10,7 +10,20 @@ spring:
|
||||
username: konosuba
|
||||
password: kKWjPDYDMLtLaLwY
|
||||
type: com.zaxxer.hikari.HikariDataSource
|
||||
|
||||
data:
|
||||
elasticsearch:
|
||||
elasticsearch:
|
||||
uris: localhost:9200
|
||||
cluster-name: elasticsearch
|
||||
properties:
|
||||
http:
|
||||
enabled: true
|
||||
path: /_search
|
||||
connect-timeout: 10000
|
||||
socket-timeout: 30000
|
||||
transport:
|
||||
tcp:
|
||||
connect-timeout: 10000
|
||||
socket-timeout: 30000
|
||||
discovery:
|
||||
zen:
|
||||
ping.unicast.hosts: localhost:9300
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user