@@ -49,7 +49,7 @@ public void addQuery(String collectionName, List<TextSegment> queries) {
4949 try {
5050 EmbeddingModel embeddingModel = ModelProvider .getEmbeddingModel ();
5151 Embedding embedding = embeddingModel .embed (question ).content ();
52- boolean existSegment = existSegment (embeddingStore , query , embedding );
52+ boolean existSegment = existSegment (collectionName , embeddingStore , query , embedding );
5353 if (existSegment ) {
5454 continue ;
5555 }
@@ -62,14 +62,14 @@ public void addQuery(String collectionName, List<TextSegment> queries) {
6262 }
6363 }
6464
65- private boolean existSegment (EmbeddingStore embeddingStore , TextSegment query ,
65+ private boolean existSegment (String collectionName , EmbeddingStore embeddingStore , TextSegment query ,
6666 Embedding embedding ) {
6767 String queryId = TextSegmentConvert .getQueryId (query );
6868 if (queryId == null ) {
6969 return false ;
7070 }
7171 // Check cache first
72- Boolean cachedResult = cache .getIfPresent (queryId );
72+ Boolean cachedResult = cache .getIfPresent (collectionName + queryId );
7373 if (cachedResult != null ) {
7474 return cachedResult ;
7575 }
@@ -82,7 +82,7 @@ private boolean existSegment(EmbeddingStore embeddingStore, TextSegment query,
8282 EmbeddingSearchResult result = embeddingStore .search (request );
8383 List <EmbeddingMatch <TextSegment >> relevant = result .matches ();
8484 boolean exists = CollectionUtils .isNotEmpty (relevant );
85- cache .put (queryId , exists );
85+ cache .put (collectionName + queryId , exists );
8686 return exists ;
8787 }
8888
0 commit comments