Skip to content

Commit 2216d2b

Browse files
authored
feat: add path to search results (#126)
* feat: add path to search results * refactor: remove obsolete code
1 parent 7dd246a commit 2216d2b

6 files changed

Lines changed: 843 additions & 373 deletions

File tree

server/api/search.go

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package api
22

33
import (
44
"context"
5-
"strings"
5+
"fmt"
66

77
"github.com/odpf/stencil/server/domain"
88
stencilv1beta1 "github.com/odpf/stencil/server/odpf/stencil/v1beta1"
@@ -29,20 +29,13 @@ func (a *API) Search(ctx context.Context, in *stencilv1beta1.SearchRequest) (*st
2929

3030
hits := make([]*stencilv1beta1.SearchHits, 0)
3131
for _, hit := range res.Hits {
32-
for _, k := range hit.Keys {
33-
li := strings.LastIndex(k, ".")
34-
if strings.HasPrefix(k[:li], "m_") {
35-
hit.Types = append(hit.Types, k[2:li])
36-
} else {
37-
hit.Fields = append(hit.Fields, k[2:li])
38-
}
39-
}
4032
hits = append(hits, &stencilv1beta1.SearchHits{
4133
SchemaId: hit.SchemaID,
4234
VersionId: hit.VersionID,
4335
Fields: hit.Fields,
4436
Types: hit.Types,
4537
NamespaceId: hit.NamespaceID,
38+
Path: fmt.Sprintf("/v1beta1/namespaces/%s/schemas/%s/versions/%d", hit.NamespaceID, hit.SchemaID, hit.VersionID),
4639
})
4740
}
4841
return &stencilv1beta1.SearchResponse{

server/domain/search.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ type SearchResponse struct {
2626
type SearchHits struct {
2727
Fields []string
2828
Types []string
29-
Keys []string
29+
Path string
3030
NamespaceID string
3131
SchemaID string
3232
VersionID int32

0 commit comments

Comments
 (0)