-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #160 from 0chain/feat/ftextsearch
File content Search
- Loading branch information
Showing
17 changed files
with
670 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package s3api | ||
|
||
import ( | ||
"fmt" | ||
"io" | ||
"log" | ||
"net/http" | ||
"net/url" | ||
) | ||
|
||
func searchObject(query string) ([]byte, error) { | ||
u, _ := url.Parse("http://zsearch:3003/search") | ||
q := u.Query() | ||
q.Set("query", query) | ||
u.RawQuery = q.Encode() | ||
log.Println("search url", u.String()) | ||
resp, err := http.Get(u.String()) | ||
if err != nil { | ||
return nil, fmt.Errorf("failed to make request: %w", err) | ||
} | ||
defer resp.Body.Close() | ||
|
||
body, err := io.ReadAll(resp.Body) | ||
if err != nil { | ||
return nil, fmt.Errorf("failed to read response body: %w", err) | ||
} | ||
return body, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,5 @@ use ( | |
. | ||
./client-api | ||
./cmd/gateway/zcn/multipart-test/s3gateway | ||
./zsearch | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
FROM golang:1.21-alpine | ||
|
||
RUN apk update && apk add --no-cache git | ||
|
||
WORKDIR /app | ||
|
||
COPY go.mod go.sum ./ | ||
RUN go mod download | ||
|
||
COPY . ./ | ||
|
||
RUN go build -o /zsearch | ||
|
||
# VOLUME ["/vindex"] | ||
|
||
EXPOSE 3003 | ||
|
||
CMD ["/zsearch"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package handler | ||
|
||
import ( | ||
"net/http" | ||
"zsearch/delete/model" | ||
) | ||
|
||
func DeleteHandler(delChan chan<- model.DelReq) http.HandlerFunc { | ||
return func(w http.ResponseWriter, r *http.Request) { | ||
bucketName := r.URL.Query().Get("bucketName") | ||
objName := r.URL.Query().Get("objName") | ||
delReq := model.DelReq{ | ||
Path: bucketName + "/" + objName, | ||
Filename: objName, | ||
} | ||
|
||
delChan <- delReq | ||
w.WriteHeader(http.StatusOK) | ||
w.Write([]byte("Files deleted successfully")) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package model | ||
|
||
type DelReq struct { | ||
Filename string `json:"filename"` | ||
Path string `json:"path"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
module zsearch | ||
|
||
go 1.21 | ||
|
||
require ( | ||
github.com/bbalet/stopwords v1.0.0 | ||
github.com/blevesearch/bleve/v2 v2.4.1 | ||
github.com/google/go-tika v0.3.1 | ||
) | ||
|
||
require ( | ||
github.com/RoaringBitmap/roaring v1.9.3 // indirect | ||
github.com/bits-and-blooms/bitset v1.12.0 // indirect | ||
github.com/blevesearch/bleve_index_api v1.1.9 // indirect | ||
github.com/blevesearch/geo v0.1.20 // indirect | ||
github.com/blevesearch/go-faiss v1.0.19 // indirect | ||
github.com/blevesearch/go-porterstemmer v1.0.3 // indirect | ||
github.com/blevesearch/gtreap v0.1.1 // indirect | ||
github.com/blevesearch/mmap-go v1.0.4 // indirect | ||
github.com/blevesearch/scorch_segment_api/v2 v2.2.14 // indirect | ||
github.com/blevesearch/segment v0.9.1 // indirect | ||
github.com/blevesearch/snowballstem v0.9.0 // indirect | ||
github.com/blevesearch/upsidedown_store_api v1.0.2 // indirect | ||
github.com/blevesearch/vellum v1.0.10 // indirect | ||
github.com/blevesearch/zapx/v11 v11.3.10 // indirect | ||
github.com/blevesearch/zapx/v12 v12.3.10 // indirect | ||
github.com/blevesearch/zapx/v13 v13.3.10 // indirect | ||
github.com/blevesearch/zapx/v14 v14.3.10 // indirect | ||
github.com/blevesearch/zapx/v15 v15.3.13 // indirect | ||
github.com/blevesearch/zapx/v16 v16.1.4 // indirect | ||
github.com/golang/geo v0.0.0-20210211234256-740aa86cb551 // indirect | ||
github.com/golang/protobuf v1.3.2 // indirect | ||
github.com/golang/snappy v0.0.1 // indirect | ||
github.com/json-iterator/go v0.0.0-20171115153421-f7279a603ede // indirect | ||
github.com/mschoch/smat v0.2.0 // indirect | ||
go.etcd.io/bbolt v1.3.7 // indirect | ||
golang.org/x/net v0.23.0 // indirect | ||
golang.org/x/sys v0.18.0 // indirect | ||
golang.org/x/text v0.14.0 // indirect | ||
) |
Oops, something went wrong.