https://github.com/geta/epi.find.extensions
Extension methods for EPiServer Find.
https://github.com/geta/epi.find.extensions
search
Last synced: about 1 year ago
JSON representation
Extension methods for EPiServer Find.
- Host: GitHub
- URL: https://github.com/geta/epi.find.extensions
- Owner: Geta
- License: apache-2.0
- Created: 2014-12-16T09:11:49.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2022-12-07T20:29:47.000Z (over 3 years ago)
- Last Synced: 2025-02-08T17:44:46.760Z (over 1 year ago)
- Topics: search
- Language: C#
- Size: 44.1 MB
- Stars: 1
- Watchers: 25
- Forks: 0
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
## Geta.EPi.Find.Extensions
* Master
,branch:master/statusIcon)
* Develop
,branch:develop/statusIcon)
[](https://msdn.microsoft.com/en-us/library/w0x726c2%28v=vs.110%29.aspx)
[](http://world.episerver.com/cms/)
## Description
Extension methods for EPiServer Find.
## Features
- Conditional filtering: Adds an easy way to add filters based on a condition.
- Terms Facet: Retrieve TermsFacet for int properties instead of string properties.
- Wildcards: Allows you to perform queries with wildcards.
## Examples
### Conditional filtering
```csharp
int? someId = ....;
var searchResult = client.Search()
.Filter(x => x.ExampleProp1.Match(true))
// Only apply filter if someId has a value
.Conditional(someId.HasValue, r => r.Filter(x => x.ExampleProp2.Match(someId.Value)))
.Filter(x => x.ExampleProp3);
```
### TermsFacetFor on int / number properties
Useful if you want to have the termfacet for a given id property (where the id is an int obviously).
```csharp
public class Test {
public virtual string StringProp { get; set; }
public virtual int IntProp { get; set; }
}
var searchResult = client.Search()
.Take(0)
.TermsFacetFor(x => x.StringProp)
// TermsFacetFor only exists for string properties
// The actual api works with ints (numbers) as well
.TermsFacetFor(x => x.IntProp);
```
### TermsFacetFor result size (take)
Being able to set result size for termfacet, easily discoverable by IntelliSense.
```csharp
var resultSize = 1000;
var searchResult = client.Search()
.Take(0)
// Easily add resultSize to TermsFacetFor
.TermsFacetFor(x => x.IntProp, resultSize)
// Resharper/IntelliSense does not like this notation too much
// And you obviously want to use it on int properties as well right!?
.TermsFacetFor(x => x.StringProp, r => r.Size = resultSize);
```
### Wildcards
```csharp
return typeSearch.For(query, stringQuery =>
{
stringQuery.Query = AddWildcards(stringQuery.Query.ToString());
stringQuery.AllowLeadingWildcard = allowLeadingWildcard;
stringQuery.AnalyzeWildcard = analyzeWildCard;
stringQuery.FuzzyMinSim = fuzzyMinSim;
});
```
### Wildcards with best bets applied
```csharp
var searchResult = SearchClient.Instance.Search()
.ForWithWildcards(searchQuery, (x => x.Title, 1.5), (x => x.Name, 0.5))
.GetContentResultSafe();
```
### Handle Client and Service exceptions
Makes it easy to return an empty results instead of an error, useful in case find is unstable/down. See [this](https://world.episerver.com/blogs/Jonas-Bergqvist/Dates/2016/12/exceptions-in-find/) and [this](https://www.brianweet.com/2017/03/17/handling-find-serviceexception.html)
```csharp
// Throws exception
var contentResult = search
.GetContentResult(cacheForSeconds, cacheForEditorsAndAdmins);
// Returns empty result in case of ClientException or ServiceException
var contentResult = search
.GetContentResultSafe(cacheForSeconds, cacheForEditorsAndAdmins);
```
## Local development setup
See description in [shared repository](https://github.com/Geta/package-shared/blob/master/README.md#local-development-set-up) regarding how to setup local development environment.
### Docker hostnames
Instead of using the static IP addresses the following hostnames can be used out-of-the-box.
- http://find-extensions.getalocaltest.me
## Package Maintainer
https://github.com/DigIntSys
## Changelog
[Changelog](CHANGELOG.md)