This commit is contained in:
luke 2025-05-20 08:50:26 +08:00
parent 821bec35b5
commit 16a6eeab86
4 changed files with 82 additions and 1 deletions

28
config/01-创建es索引 Normal file
View 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
View File

@ -33,6 +33,8 @@
<commons-lang3.version>3.12.0</commons-lang3.version>
<hutool-all.version>5.7.20</hutool-all.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>
<dependencyManagement>
<dependencies>
@ -149,6 +151,14 @@
<version>${guava.version}</version>
</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>
</dependencyManagement>
@ -252,6 +262,11 @@
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-high-level-client</artifactId>
</dependency>
</dependencies>
<build>

View File

@ -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))
);
}
}

View File

@ -9,4 +9,14 @@ log4j2.enable.threadlocals=true
logging.level.com.doc.parser=info
logging.level.root=${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/设计模式