diff --git a/index_impl.go b/index_impl.go index 0286e4e1..cc481cc0 100644 --- a/index_impl.go +++ b/index_impl.go @@ -497,6 +497,12 @@ func (i *indexImpl) Search(req *SearchRequest) (sr *SearchResult, err error) { } } + for _, hit := range hits { + if i.name != "" { + hit.Index = i.name + } + } + atomic.AddUint64(&i.stats.searches, 1) searchDuration := time.Since(searchStart) atomic.AddUint64(&i.stats.searchTime, uint64(searchDuration)) diff --git a/search/search.go b/search/search.go index f7e283a4..cc4b175c 100644 --- a/search/search.go +++ b/search/search.go @@ -51,6 +51,7 @@ type FieldTermLocationMap map[string]TermLocationMap type FieldFragmentMap map[string][]string type DocumentMatch struct { + Index string `json:"index,omitempty"` ID string `json:"id"` Score float64 `json:"score"` Expl *Explanation `json:"explanation,omitempty"`