Skip to content

Commit

Permalink
Reference shared field names from schema (#7711)
Browse files Browse the repository at this point in the history
Remove duplicate const names.
  • Loading branch information
tylerwilliams authored Oct 9, 2024
1 parent 7cd9c98 commit 113bc95
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions codesearch/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,6 @@ const (
// mimetype detection.
detectionBufferSize = 1000

// The following field names are used in the indexed docs.
filenameField = "filename"
contentField = "content"
languageField = "language"
ownerField = "owner"
repoField = "repo"
shaField = "sha"

// Used to control how many results may be returned at a time.
defaultNumResults = 10
maxNumResults = 1000
Expand Down Expand Up @@ -288,11 +280,11 @@ func (css *codesearchServer) Search(ctx context.Context, req *srpb.SearchRequest
}

result := &srpb.Result{
Owner: string(doc.Field(ownerField).Contents()),
Repo: string(doc.Field(repoField).Contents()),
Filename: string(doc.Field(filenameField).Contents()),
Owner: string(doc.Field(schema.OwnerField).Contents()),
Repo: string(doc.Field(schema.RepoField).Contents()),
Filename: string(doc.Field(schema.FilenameField).Contents()),
MatchCount: int32(len(dedupedRegions)),
Sha: string(doc.Field(shaField).Contents()),
Sha: string(doc.Field(schema.SHAField).Contents()),
}
for _, region := range dedupedRegions {
result.Snippets = append(result.Snippets, &srpb.Snippet{
Expand Down

0 comments on commit 113bc95

Please sign in to comment.