'commit'
This commit is contained in:
@@ -108,6 +108,37 @@ class EsSearchUtil:
|
||||
# 释放连接回连接池
|
||||
self.es_pool.release_connection(conn)
|
||||
|
||||
def select_all_data(self, size=1000):
|
||||
"""
|
||||
查询索引中的所有数据
|
||||
|
||||
参数:
|
||||
size: 返回的最大结果数量,默认1000
|
||||
|
||||
返回:
|
||||
dict: 查询结果
|
||||
"""
|
||||
# 从连接池获取连接
|
||||
conn = self.es_pool.get_connection()
|
||||
try:
|
||||
# 构建查询条件 - 匹配所有文档
|
||||
query = {
|
||||
"query": {
|
||||
"match_all": {}
|
||||
},
|
||||
"size": size
|
||||
}
|
||||
|
||||
# 执行查询
|
||||
response = conn.search(index=self.es_config['index_name'], body=query)
|
||||
return response
|
||||
except Exception as e:
|
||||
logger.error(f"查询所有数据失败: {str(e)}")
|
||||
raise
|
||||
finally:
|
||||
# 释放连接回连接池
|
||||
self.es_pool.release_connection(conn)
|
||||
|
||||
def split_text_into_chunks(self,text: str, chunk_size: int = 200, chunk_overlap: int = 0) -> list:
|
||||
"""
|
||||
将文本切割成块
|
||||
|
Reference in New Issue
Block a user