Skip to content

Commit

Permalink
only existing
Browse files Browse the repository at this point in the history
  • Loading branch information
jackdoe committed Apr 15, 2020
1 parent a0d31b5 commit cc22931
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions pkg/data/shard.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,11 @@ func (s *Shard) MakeQuery(field string, query string) iq.Query {
for i := 0; i < MAX_CHUNKS; i++ {
and := []iq.Query{}
for _, w := range ws {
term := fmt.Sprintf("%s_%d", w, i)
q := s.Dir.NewTermQuery(field, term)
and = append(and, q)
if len(w) > 0 {
term := fmt.Sprintf("%s_%d", w, i)
q := s.Dir.NewTermQuery(field, term)
and = append(and, q)
}
}
or = append(or, iq.Constant(float32(1+MAX_CHUNKS-i), andOrFirst(and)))
}
Expand All @@ -117,9 +119,11 @@ func (s *Shard) MakeQuery(field string, query string) iq.Query {
not := []iq.Query{}
for i := 0; i < MAX_CHUNKS; i++ {
for _, w := range ws {
term := fmt.Sprintf("%s_%d", w, i)
q := s.Dir.NewTermQuery(field, term)
not = append(not, q)
if len(w) > 0 {
term := fmt.Sprintf("%s_%d", w, i)
q := s.Dir.NewTermQuery(field, term)
not = append(not, q)
}
}
}

Expand Down

0 comments on commit cc22931

Please sign in to comment.