(feature)(headless)Support offset clause in struct query.
Some checks failed
supersonic CentOS CI / build (21) (push) Has been cancelled
supersonic mac CI / build (21) (push) Has been cancelled
supersonic ubuntu CI / build (21) (push) Has been cancelled
supersonic windows CI / build (21) (push) Has been cancelled

This commit is contained in:
jerryjzhang
2025-03-23 14:30:56 +08:00
parent db8f340e2d
commit d2a43a99c8
7 changed files with 29 additions and 22 deletions

View File

@@ -49,7 +49,8 @@ public class EmbeddingServiceImpl implements EmbeddingService {
try {
EmbeddingModel embeddingModel = ModelProvider.getEmbeddingModel();
Embedding embedding = embeddingModel.embed(question).content();
boolean existSegment = existSegment(collectionName,embeddingStore, query, embedding);
boolean existSegment =
existSegment(collectionName, embeddingStore, query, embedding);
if (existSegment) {
continue;
}
@@ -62,14 +63,14 @@ public class EmbeddingServiceImpl implements EmbeddingService {
}
}
private boolean existSegment(String collectionName,EmbeddingStore embeddingStore, TextSegment query,
Embedding embedding) {
private boolean existSegment(String collectionName, EmbeddingStore embeddingStore,
TextSegment query, Embedding embedding) {
String queryId = TextSegmentConvert.getQueryId(query);
if (queryId == null) {
return false;
}
// Check cache first
Boolean cachedResult = cache.getIfPresent(collectionName+queryId);
Boolean cachedResult = cache.getIfPresent(collectionName + queryId);
if (cachedResult != null) {
return cachedResult;
}
@@ -82,7 +83,7 @@ public class EmbeddingServiceImpl implements EmbeddingService {
EmbeddingSearchResult result = embeddingStore.search(request);
List<EmbeddingMatch<TextSegment>> relevant = result.matches();
boolean exists = CollectionUtils.isNotEmpty(relevant);
cache.put(collectionName+queryId, exists);
cache.put(collectionName + queryId, exists);
return exists;
}