Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
Client is a goreds client that uses a Redis client and Namespace to perform searches
func NewClient ¶
NewClient will create a new search client with the given redigo connection and namespace (defaults to "goreds"). You may create multiple clients with different namespaces for separate search indexes.
Example ¶
package main
import (
"fmt"
"github.com/garyburd/redigo/redis"
"blainsmith.com/go/goreds"
)
func main() {
redis, _ := redis.DialURL("redis://localhost:6379")
search := goreds.NewClient(redis, "namespace")
// index some text and assign to their id
search.Index("example index text", "1")
search.Index("example text being indexed for the sake of this example", "2")
search.Index("example testing with a lot more text", "3")
search.Index("index some more sample text data", "4")
// remove an item from the search index
search.Remove("2")
// query the search index that should match ids 1 and 4
ids, _ := search.Query("index text", goreds.AND)
fmt.Println(ids)
}
Output: [4 1]
func (*Client) Index ¶
Index will store the `id` within the database and use the `text` as the searchable text
func (*Client) Query ¶
Query performs a search against the database and returns a slice of ids that match
Source Files
¶
- goreds.go
Click to show internal directories.
Click to hide internal directories.