README
goreds
goreds is a Go port of tj/reds for Node.js
About
via https://github.com/tj/reds#about
Currently reds strips stop words and applies the metaphone and porter stemmer algorithms to the remaining words before mapping the constants in Redis sets. For example the following text:
Tobi is a ferret and he only wants four dollars
Converts to the following constant map:
map[Tobi:TB ferret:FRT wants:WNTS four:FR dollars:DLRS]
This also means that phonetically similar words will match, for example "stefen", "stephen", "steven" and "stefan" all resolve to the constant "STFN". Reds takes this further and applies the porter stemming algorithm to "stem" words, for example "counts", and "counting" become "count".
Consider we have the following bodies of text:
Tobi really wants four dollars
For some reason tobi is always wanting four dollars
The following search query will then match both of these bodies, and "wanting", and "wants" both reduce to "want".
tobi wants four dollars
Example
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]
Documentation
Index ¶
Examples ¶
Constants ¶
Variables ¶
Functions ¶
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.
func (*Client) Index ¶
Index will store the `id` within the database and use the `text` as the searchable text
Directories
Path | Synopsis |
---|---|