From ef69a238681969531ebba5ceb69c6376d0f25c02 Mon Sep 17 00:00:00 2001 From: Corentin Kerisit Date: Mon, 7 Mar 2016 18:53:34 +0100 Subject: [PATCH] Adds source filtering for SearchDsl This is different from the Fields methods as ElasticSearch will return a _source with only the fields specified. --- lib/searchsearch.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/searchsearch.go b/lib/searchsearch.go index c921ae5a..c7efd7f3 100644 --- a/lib/searchsearch.go +++ b/lib/searchsearch.go @@ -124,6 +124,10 @@ func (s *SearchDsl) Source(returnSource bool) *SearchDsl { return s } +func (s *SearchDsl) SourceFields(fields ...string) *SearchDsl { + s.args["_source"] = fields + return s +} // Facet passes a Query expression to this search // // qry := Search("github").Size("0").Facet(