Open-source LLM knowledge platform: turn raw documents into a queryable RAG, an autonomous reasoning agent, and a self-maintaining Wiki.
Go agentagenticaichatbotdsh-pluginembeddingsevaluationgenerative-aigolangknowledge-basellmmulti-tenantollamaopenaiquestion-answeringragrerankingsemantic-searchvector-searchwiki
perf(repository): exclude embedding field from Elasticsearch search response to reduce size
MarionMa0a9a9204607a
diff --git a/internal/application/repository/retriever/elasticsearch/v8/repository.go b/internal/application/repository/retriever/elasticsearch/v8/repository.goindex 83a489d19..57ce52adf 100644--- a/internal/application/repository/retriever/elasticsearch/v8/repository.go+++ b/internal/application/repository/retriever/elasticsearch/v8/repository.go@@ -433,12 +433,17 @@ func (e *elasticsearchRepository) VectorRetrieve(ctx context.Context,},MinScore: &minScore,}+ // Exclude embedding field from source to reduce response size+ sourceFilter := &types.SourceFilter{+ Excludes: []string{"embedding"},+ }log.Debugf("[Elasticsearch] Executing vector search in index: %s", e.index)// Execute search with minimum score thresholdresponse, err := e.client.Search().Index(e.index).Request(&search.Request{- Query: &types.Query{ScriptScore: scriptScore},- Size: ¶ms.TopK,+ Query: &types.Query{ScriptScore: scriptScore},+ Size: ¶ms.TopK,+ Source_: sourceFilter,}).Do(ctx)if err != nil {log.Errorf("[Elasticsearch] Vector search failed: %v", err)@@ -488,11 +493,16 @@ func (e *elasticsearchRepository) KeywordsRetrieve(ctx context.Context,must := []types.Query{{Match: map[string]types.MatchQuery{"content": {Query: params.Query}}},}+ // Exclude embedding field from source to reduce response size+ sourceFilter := &types.SourceFilter{+ Excludes: []string{"embedding"},+ }log.Debugf("[Elasticsearch] Executing keyword search in index: %s", e.index)response, err := e.client.Search().Index(e.index).Request(&search.Request{- Query: &types.Query{Bool: &types.BoolQuery{Filter: filter, Must: must}},- Size: ¶ms.TopK,+ Query: &types.Query{Bool: &types.BoolQuery{Filter: filter, Must: must}},+ Size: ¶ms.TopK,+ Source_: sourceFilter,}).Do(ctx)if err != nil {log.Errorf("[Elasticsearch] Keywords search failed: %v", err)