add es
This commit is contained in:
parent
821bec35b5
commit
16a6eeab86
28
config/01-创建es索引
Normal file
28
config/01-创建es索引
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
PUT /documents
|
||||||
|
{
|
||||||
|
"settings": {
|
||||||
|
"analysis": {
|
||||||
|
"analyzer": {
|
||||||
|
"my_chinese_analyzer": {
|
||||||
|
"type": "custom",
|
||||||
|
"tokenizer": "ik_max_word"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"mappings": {
|
||||||
|
"properties": {
|
||||||
|
"filename": {
|
||||||
|
"type": "keyword"
|
||||||
|
},
|
||||||
|
"filepath": {
|
||||||
|
"type": "keyword"
|
||||||
|
},
|
||||||
|
"content": {
|
||||||
|
"type": "text",
|
||||||
|
"analyzer": "ik_max_word",
|
||||||
|
"search_analyzer": "ik_smart"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
15
pom.xml
15
pom.xml
@ -33,6 +33,8 @@
|
|||||||
<commons-lang3.version>3.12.0</commons-lang3.version>
|
<commons-lang3.version>3.12.0</commons-lang3.version>
|
||||||
<hutool-all.version>5.7.20</hutool-all.version>
|
<hutool-all.version>5.7.20</hutool-all.version>
|
||||||
<guava.version>31.0.1-jre</guava.version>
|
<guava.version>31.0.1-jre</guava.version>
|
||||||
|
|
||||||
|
<elasticsearch-rest-high-level-client.version>7.17.10</elasticsearch-rest-high-level-client.version>
|
||||||
</properties>
|
</properties>
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
@ -149,6 +151,14 @@
|
|||||||
<version>${guava.version}</version>
|
<version>${guava.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Elasticsearch 客户端 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.elasticsearch.client</groupId>
|
||||||
|
<artifactId>elasticsearch-rest-high-level-client</artifactId>
|
||||||
|
<version>${elasticsearch-rest-high-level-client.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
|
||||||
@ -252,6 +262,11 @@
|
|||||||
<artifactId>guava</artifactId>
|
<artifactId>guava</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.elasticsearch.client</groupId>
|
||||||
|
<artifactId>elasticsearch-rest-high-level-client</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|||||||
@ -0,0 +1,28 @@
|
|||||||
|
package com.doc.parser.infrastructure.config;
|
||||||
|
|
||||||
|
import org.apache.http.HttpHost;
|
||||||
|
import org.elasticsearch.client.RestClient;
|
||||||
|
import org.elasticsearch.client.RestHighLevelClient;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class ElasticsearchConfig {
|
||||||
|
|
||||||
|
@Value("${elasticsearch.host}")
|
||||||
|
private String host;
|
||||||
|
|
||||||
|
@Value("${elasticsearch.port}")
|
||||||
|
private int port;
|
||||||
|
|
||||||
|
@Value("${elasticsearch.scheme}")
|
||||||
|
private String scheme;
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public RestHighLevelClient esClient() {
|
||||||
|
return new RestHighLevelClient(
|
||||||
|
RestClient.builder(new HttpHost(host, port, scheme))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -9,4 +9,14 @@ log4j2.enable.threadlocals=true
|
|||||||
logging.level.com.doc.parser=info
|
logging.level.com.doc.parser=info
|
||||||
logging.level.root=${logging.level.com.doc.parser}
|
logging.level.root=${logging.level.com.doc.parser}
|
||||||
logging.org.springframework.web=${logging.level.com.doc.parser}
|
logging.org.springframework.web=${logging.level.com.doc.parser}
|
||||||
logging.org.springframework.context=${logging.level.com.doc.parser}
|
logging.org.springframework.context=${logging.level.com.doc.parser}
|
||||||
|
|
||||||
|
|
||||||
|
# ES相关
|
||||||
|
elasticsearch.host=localhost
|
||||||
|
elasticsearch.port=9200
|
||||||
|
elasticsearch.scheme=http
|
||||||
|
|
||||||
|
|
||||||
|
# 导入的材料路径
|
||||||
|
markdown.path = D:/02-documents/01-ahnx-share-src-public/public/设计模式
|
||||||
Loading…
x
Reference in New Issue
Block a user