From 24b4348f7a12d9224e02d8c1d2cbc2a9af2a900b Mon Sep 17 00:00:00 2001 From: Marty Schoch Date: Mon, 21 Jul 2014 16:48:01 -0400 Subject: [PATCH] fix bug in phrase search on composite fields now correctly finds phrases in any of the contributing fields --- search/search_phrase.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/search/search_phrase.go b/search/search_phrase.go index 09c56d08..a413ebbd 100644 --- a/search/search_phrase.go +++ b/search/search_phrase.go @@ -109,11 +109,11 @@ func (s *PhraseSearcher) SetQueryNorm(qnorm float64) { func (s *PhraseSearcher) Next() (*DocumentMatch, error) { var rv *DocumentMatch for s.currMust != nil { - rvtlm := make(TermLocationMap, 0) + rvftlm := make(FieldTermLocationMap, 0) freq := 0 firstTerm := s.query.Terms[0] - termLocMap, ok := s.currMust.Locations[firstTerm.Field] - if ok { + for field, termLocMap := range s.currMust.Locations { + rvtlm := make(TermLocationMap, 0) locations, ok := termLocMap[firstTerm.Term] if ok { OUTER: @@ -136,12 +136,15 @@ func (s *PhraseSearcher) Next() (*DocumentMatch, error) { } // if we got here we didnt find location match for this term continue OUTER + } else { + continue OUTER } } } // if we got here all the terms matched freq += 1 mergeTermLocationMaps(rvtlm, crvtlm) + rvftlm[field] = rvtlm } } } @@ -149,9 +152,7 @@ func (s *PhraseSearcher) Next() (*DocumentMatch, error) { if freq > 0 { // return match rv = s.currMust - rv.Locations = FieldTermLocationMap{ - firstTerm.Field: rvtlm, - } + rv.Locations = rvftlm s.advanceNextMust() return rv, nil }