프로젝트
GitHub에서 보기
RediSearch/redisearch-go
소개
Go client for RediSearch
데이터 및 분석측정된 스타 증가
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- -1
- in 1 month
- 기록 수집 중
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
README.md
OriginalRediSearch Go Client
Go client for RediSearch, based on redigo.
Installing
go get github.com/RediSearch/redisearch-go/redisearch
Usage Example
package main
import (
"fmt"
"log"
"time"
"github.com/RediSearch/redisearch-go/redisearch"
)
func ExampleClient() {
// Create a client. By default a client is schemaless
// unless a schema is provided when creating the index
c := redisearch.NewClient("localhost:6379", "myIndex")
// Create a schema
sc := redisearch.NewSchema(redisearch.DefaultOptions).
AddField(redisearch.NewTextField("body")).
AddField(redisearch.NewTextFieldOptions("title", redisearch.TextFieldOptions{Weight: 5.0, Sortable: true})).
AddField(redisearch.NewNumericField("date"))
// Drop an existing index. If the index does not exist an error is returned
c.Drop()
// Create the index with the given schema
if err := c.CreateIndex(sc); err != nil {
log.Fatal(err)
}
// Create a document with an id and given score
doc := redisearch.NewDocument("doc1", 1.0)
doc.Set("title", "Hello world").
Set("body", "foo bar").
Set("date", time.Now().Unix())
// Index the document. The API accepts multiple documents at a time
if err := c.Index([]redisearch.Document{doc}...); err != nil {
log.Fatal(err)
}
// Searching with limit and sorting
docs, total, err := c.Search(redisearch.NewQuery("hello world").
Limit(0, 2).
SetReturnFields("title"))
fmt.Println(docs[0].Id, docs[0].Properties["title"], total, err)
// Output: doc1 Hello world 1 <nil>
}
Supported RediSearch Commands
관련 프로젝트 살펴보기
불러오는 중…