this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Revert "add sorting and pagination and 'and' to search"

This reverts commit e73869a3913aed4471682c58f55ca2ce0c968f1c.

+13 -43
+1 -29
search/handlers.go
··· 2 2 3 3 import ( 4 4 "context" 5 - "fmt" 6 - "strconv" 7 5 "strings" 8 6 9 7 api "github.com/bluesky-social/indigo/api" ··· 37 35 }) 38 36 } 39 37 40 - offset := 0 41 - if q := strings.TrimSpace(e.QueryParam("offset")); q != "" { 42 - v, err := strconv.Atoi(q) 43 - if err != nil { 44 - return &echo.HTTPError{ 45 - Code: 400, 46 - Message: fmt.Sprintf("invalid value for 'offset': %s", err), 47 - } 48 - } 49 - 50 - offset = v 51 - } 52 - 53 - count := 30 54 - if q := strings.TrimSpace(e.QueryParam("count")); q != "" { 55 - v, err := strconv.Atoi(q) 56 - if err != nil { 57 - return &echo.HTTPError{ 58 - Code: 400, 59 - Message: fmt.Sprintf("invalid value for 'count': %s", err), 60 - } 61 - } 62 - 63 - count = v 64 - } 65 - 66 - out, err := s.SearchPosts(ctx, q, offset, count) 38 + out, err := s.SearchPosts(ctx, q) 67 39 if err != nil { 68 40 return err 69 41 }
+9 -11
search/query.go
··· 44 44 Post any `json:"post"` 45 45 } 46 46 47 - func doSearchPosts(ctx context.Context, escli *es.Client, q string, offset int, size int) (*EsSearchResponse, error) { 47 + func doSearchPosts(ctx context.Context, escli *es.Client, q string) (*EsSearchResponse, error) { 48 48 query := map[string]interface{}{ 49 - "sort": map[string]any{ 50 - "createdAt": map[string]any{ 51 - "order": "desc", 49 + /* 50 + "sort": map[string]any{ 51 + "createdAt": map[string]any{ 52 + "order": "desc", 53 + "format": "date_nanos", 54 + }, 52 55 }, 53 - }, 56 + */ 54 57 "query": map[string]interface{}{ 55 58 "match": map[string]interface{}{ 56 - "text": map[string]any{ 57 - "query": q, 58 - "operator": "and", 59 - }, 59 + "text": q, 60 60 }, 61 61 }, 62 - "size": size, 63 - "from": offset, 64 62 } 65 63 66 64 return doSearch(ctx, escli, "posts", query)
+3 -3
search/server.go
··· 25 25 "github.com/ipfs/go-cid" 26 26 flatfs "github.com/ipfs/go-ds-flatfs" 27 27 blockstore "github.com/ipfs/go-ipfs-blockstore" 28 - logging "github.com/ipfs/go-log" 29 28 "github.com/labstack/echo/v4" 30 29 "github.com/labstack/echo/v4/middleware" 31 30 es "github.com/opensearch-project/opensearch-go/v2" 32 31 gorm "gorm.io/gorm" 32 + logging "github.com/ipfs/go-log" 33 33 ) 34 34 35 35 var log = logging.Logger("search") ··· 282 282 }) 283 283 } 284 284 285 - func (s *Server) SearchPosts(ctx context.Context, srch string, offset, size int) ([]PostSearchResult, error) { 286 - resp, err := doSearchPosts(ctx, s.escli, srch, offset, size) 285 + func (s *Server) SearchPosts(ctx context.Context, srch string) ([]PostSearchResult, error) { 286 + resp, err := doSearchPosts(ctx, s.escli, srch) 287 287 if err != nil { 288 288 return nil, err 289 289 }