Redisearch 메타데이터 누락 버그 해결

GreatCloud·2026년 4월 17일

백엔드

목록 보기
12/14

문제상황

클라이밍 커뮤니티 서비스의 게시글 RAG 검색 기능을 개발하던 도중
Redisearch 조회 수행시 메타데이터가 받아져오지 않는 버그가 발생했다.

climbingwith-app       | 2026-04-17T09:40:06.593Z  INFO 1 --- [ClimbingWith] [nio-8080-exec-1] c.p.g.C.service.VectorService            : 조회시도 id list: []
climbingwith-app       | 2026-04-17T09:40:06.593Z  INFO 1 --- [ClimbingWith] [nio-8080-exec-1] c.p.g.C.service.VectorService            : 검색결과: 0
climbingwith-app       | 2026-04-17T09:40:06.622Z  INFO 1 --- [ClimbingWith] [nio-8080-exec-1] c.p.g.C.service.VectorService            : 게시물 조회: []                                                       
climbingwith-app       | 2026-04-17T09:40:06.622Z  INFO 1 ---

원인 분석

RedisSearch 저장은 제대로 되어 있는 상황이다.

첫번째 문제

EmbeddingStore 설정 등록 문제
metadatakeys 설정 누락으로 인해 인덱스 생성시 postId가 누락된 스키마가 생성되었다.
그렇기에 추가해서 재빌드를 해보았으나

@Configuration
public class VectorStoreConfig {
    @Bean
    public EmbeddingStore<TextSegment> embeddingStore(){
        return RedisEmbeddingStore.builder()
                .host("vector")
                .port(6379)
                .dimension(1024) //bge-m3 차원
                .metadataKeys(List.of("postId")) // << 누락!
                .indexName("climbing-knowledge-Index")
                .build();
    }
}

여전히 조회되지 않고있다.

10:00:41.000Z. Current time: 2026-04-17T10:04:10.312Z. Allowed clock skew: 0 milliseconds.
climbingwith-app       | 2026-04-17T10:04:13.563Z  INFO 1 --- [ClimbingWith] [nio-8080-exec-1] c.p.g.C.r.impl.VectorRepositoryImpl      : 검색어: 분실물, 검색 갯수: 10
climbingwith-app       | 2026-04-17T10:04:13.578Z  INFO 1 --- [ClimbingWith] [nio-8080-exec-1] c.p.g.C.r.impl.VectorRepositoryImpl      : 검색결과 여부: true
climbingwith-app       | 2026-04-17T10:04:13.579Z  INFO 1 --- [ClimbingWith] [nio-8080-exec-1] c.p.g.C.r.impl.VectorRepositoryImpl      : 검색된 메타데이터: [{}, {}, {}, {}, {}, {}, {}, {}, {}, {}]

두번째 문제

LangChain4j의 인덱스 체크로직
RedisSearch는 인덱스를 처음 생성할 때 인덱스 존재 여부를 확인하고

  • 인덱스가 없으면: 사용자가 작성한 Config를 토대로 신규 인덱스를 생성(FT.CREATE).
  • 인덱스가 있으면: Config가 수정되었더라도 무시하고 기존 인덱스를 그대로 사용한다.

해결방법

다른 문제가 아니라 인덱스를 삭제하고 다시 주면된다고 한다..

  1. redis-cli 접속
  2. FT.DROPINDEX climbing-knowledge-Index (기존 인덱스 삭제)
  3. (선택)인덱스가 없는 동안 저장되는 경우가 있을 경우 정합성을 위해 데이터를 전부 날리고 다시 저장하는게 좋을 수도 있다
profile
모르는 것에 부끄러워 말고 아는 것에 자만하지 말 것

0개의 댓글