Skip to content

Commit

Permalink
ENDPOINT-11006-Hunt-label-counter (#144)
Browse files Browse the repository at this point in the history
Fix counter when a tag label is selected while creating a hunt
  • Loading branch information
emcgee-work authored Jul 4, 2024
1 parent 7b8c34e commit e349780
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions services/indexing/indexing.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package indexing
import (
"context"
"errors"
"strings"
"sync"

cvelo_api "www.velocidex.com/golang/cloudvelo/schema/api"
Expand Down Expand Up @@ -71,6 +70,22 @@ func (self Indexer) getIndexRecords(
}
}

const searchlabel = `
{"sort": [{
"client_id": {"order": "asc", "unmapped_type": "keyword"}
}],
"query": {
"bool": {
"must": [
%s, {"match": {
"doc_type": "clients"
}}]
}
}
,"_source":{"includes":["client_id"]}
}
`

// Search the index for clients matching the term
func (self Indexer) SearchIndexWithPrefix(
ctx context.Context,
Expand All @@ -97,10 +112,9 @@ func (self Indexer) SearchIndexWithPrefix(
return

case "label":
terms := []string{json.Format(fieldSearchQuery, "labels", term)}
terms := json.Format(fieldSearchQuery, "labels", term)
query := json.Format(
getAllClientsQuery, strings.Join(terms, ","),
`,{"_source":{"includes":["client_id"]}}`)
searchlabel, terms)
self.getIndexRecords(ctx, config_obj, query, output_chan)
return

Expand Down

0 comments on commit e349780

Please sign in to comment.