Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/can-sahin/stackexchange.redis.wordsearch

AutoCompletion/WordSearch extension for StackExchange.Redis
https://github.com/can-sahin/stackexchange.redis.wordsearch

autocompletion redis stackexchange-redis

Last synced: 25 days ago
JSON representation

AutoCompletion/WordSearch extension for StackExchange.Redis

Awesome Lists containing this project

README

        

# StackExchange.Redis.WordSearch

AutoComplete, Word Search extension for [StackExchange.Redis] implemented with internal Redis Data Structures.
Extra features:
1. Raw/serialized data attachment to a searchable word.
2. Popularity Ranking

# Requirements
1. `.NET Standards 1.6`
2. `StackExchange.Redis 1.2.6`

# Installation
`PM> Install-Package StackExchange.Redis.WordSearch`

or

`$ dotnet add package StackExchange.Redis.WordSearch`

**See the [docs] for usage and examples**

# Basic Usage
For basic AutoCompletion:
```csharp
// IDatabase database = ConnectionMultiplexer.GetDatabase();
IRedisWordSearch redisSearch = new RedisWordSearch(database); //Use IRedisWordSearch to see the xml documentation
redisSearch.Add("IdOfWatson", "EmmaWatson");
redisSearch.Add("IdOfStone", "EmmaStone");

List results = redisSearch.Search("Emm").AsStringList();
// ["EmmaWatson", "EmmaStone"]
// Also supports "mma" style searches
```
Ranking Popular Searches:
```csharp
// IDatabase database = ConnectionMultiplexer.GetDatabase();
RedisWordSearchConfiguration config = RedisWordSearchConfiguration.defaultConfig;
config.RankingProvider = new CurrentlyPopularRanking(ANCHOR_EPOCH, 24); //24 hours half life

IRedisWordSearch redisSearch = new RedisWordSearch(database, config);
redisSearch.Add("IdOfWatson", "EmmaWatson");
redisSearch.Add("IdOfStone", "EmmaStone");

// Typically when application-side clicks/votes/interacts to a search result
redisSearch.BoostInRanking("IdOfStone");
redisSearch.BoostInRanking("IdOfWatson");
redisSearch.BoostInRanking("IdOfWatson");
List results = redisSearch.Search("Emma").AsStringList();
// ["EmmaWatson", "EmmaStone"] EmmaWatson is ordered first because she is twice as popular

var words = redisSearch.TopRankedSearches().AsStringList();
// ["EmmaWatson", "EmmaStone"] EmmaWatson is ordered first because she is twice as popular
```
See the [docs] for detailed `Ranking` explanation

Serialized Data:
```csharp
// IDatabase database = ConnectionMultiplexer.GetDatabase();
RedisWordSearchConfiguration config = RedisWordSearchConfiguration.defaultConfig;
config.Serializer = new MyJsonSerializer();

IRedisWordSearch wordSearch = new RedisWordSearch(database,config);
wordSearch.Add("IdOfWatson", "EmmaWatson", new PartnerForEmma("HarryPotter"));
wordSearch.Add("IdOfStone", "EmmaStone", new PartnerForEmma("PeterParker"));

List results = wordSearch.Search("Emma");
```

Use `RedisWordSearchConfiguration` to:
- Enable Popularity Ranking (default half life decay rate algorithm is implemented)
- Limit min/max search length
- Put Redis Key Prefix
- Enable Case Insensivity
- Specify searching method (autocomplete sequentially or autocomplete fuzzy search("mma" for searching "EmmaWatson")

**For details: [docs]**

# License
MIT

[StackExchange.Redis]:
[docs]: