Langchain连接Elasticsearch向量数据库创建索引报错

背景:因公司业务需求需要利用Langchain中对ES数据库的相关操作将某些文件通过embedding录入向量数据库;

代码如下

def read_excel_to_file(filepath):
    '''
    将处理好的.xls文件导入到es中,.xls文件中每一行只保留问题和答案,其他的不要
    '''
    wb = xlrd.open_workbook(filename=filepath)
    sheet1 = wb.sheet_by_index(0)
    #逐行读取excel文件
    for i in range(sheet1.nrows):
        print("".join(sheet1.row_values(i)).strip())
        #对每行读出的列表进行组合,去除首尾空格
        texts = "".join(sheet1.row_values(i)).strip()
        #设置文本切分量级
        text_splitter = TokenTextSplitter(chunk_size=1000, chunk_overlap=0)
        texts = text_splitter.create_documents([texts])
        print(texts)
        # 通过openai进行embeddings,并存入es中
        index_name = "**********"
        embeddings = llm_utils.get_custom_embeddings()
        docsearch = ElasticVectorSearch.from_documents(texts, embeddings,
                                                       elasticsearch_url="localhost:80",
                                                       index_name=index_name)
    

在录入过程中程序报错:

elasticsearch.exceptions.RequestError: RequestError(400,‘validation_exception’, ‘Validation Failed: 1: this action would add [2] total shards, but this cluster currently has [999]/[1000] maximum shards open;’)

通过查询相关资料以及询问GPT发现问题根源所在
链接:https://discuss.openedx.org/t/elasticsearch-maximum-shards-open/7319
在这里插入图片描述
导致报错的原因是由于ES向量数据的分片数已被占满,从而导致无法录入新的索引数据,解决办法就是清理无关的索引,将分片空余出来。
在这里插入图片描述

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值