Effects Composition¶
The SearchModule is an [EffectsModule(typeof(ISearchIndex<>))] that generates Eff<RT, T> effect methods for full-text search operations.
Capability Interface¶
Effect Methods¶
public static partial class SearchModule
{
public static partial class Search<T>
{
public static Eff<RT, SearchResult<T>> SearchAsync<RT>(
string query, SearchOptions? options = null)
where RT : IHasSearchIndex<T> => ...
public static Eff<RT, Unit> IndexAsync<RT>(string id, T document)
where RT : IHasSearchIndex<T> => ...
public static Eff<RT, Unit> IndexManyAsync<RT>(
IReadOnlyDictionary<string, T> documents)
where RT : IHasSearchIndex<T> => ...
public static Eff<RT, Unit> RemoveAsync<RT>(string id)
where RT : IHasSearchIndex<T> => ...
public static Eff<RT, Unit> ClearAsync<RT>()
where RT : IHasSearchIndex<T> => ...
}
}
Effect Pipeline Examples¶
Index a document after creation¶
var createAndIndex =
from product in AppStore.Products.Save<AppRuntime>(newProduct)
from _ in SearchModule.Search<Product>.IndexAsync<AppRuntime>(
product.Id.ToString(), product)
select product;
Search with options¶
var searchProducts =
from results in SearchModule.Search<Product>.SearchAsync<AppRuntime>(
"wireless headphones",
new SearchOptions { Limit = 20, Offset = 0 })
select results;