View gist:4564976
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class DictionariesWithGeolocation | |
{ | |
[Fact] | |
public void FilterByValueInDictionary() | |
{ | |
new Story("Filter by matching a key/geolocation in a dictionary") | |
.InOrderTo("be able to filter on a geolocation of a specific key in a dictionary") | |
.AsA("developer") | |
.IWant("to be able to map dictionaries to their correct value type") | |
.WithScenario("map dictionaries to their correct value type") |
View gist:4654694
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// NestedFieldNameConvention | |
// we want to nest only lists of objects not previously mapped to a specific type by EPiServer Find | |
if ((type.GetGenericTypeDefinition() == typeof(IEnumerable<>)) | |
&& !(type.GetGenericArguments()[0].IsValueType || type.GetGenericArguments()[0] == typeof(string) || type.GetGenericArguments()[0] == typeof(DateTime) || type.GetGenericArguments()[0] == typeof(CultureInfo)) | |
&& !fieldName.Contains("$$") | |
&& !fieldName.StartsWith("__")) | |
{ | |
fieldName += "$$nested"; | |
} |
View TermsFacetExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class TermsFacetExtensions | |
{ | |
public static ITypeSearch<TSource> TermsFacetFor<TSource, TListItem>(this ITypeSearch<TSource> search, Expression<Func<TSource, IEnumerable<TListItem>>> fieldListSelector, Expression<Func<TListItem, object>> fieldListItemSelector) | |
{ | |
fieldListSelector.ValidateNotNullArgument("fieldListSelector"); | |
fieldListItemSelector.ValidateNotNullArgument("fieldListItemSelector"); | |
var facetName = fieldListSelector.GetFieldPath() + "." + fieldListItemSelector.GetFieldPath(); | |
var fieldName = search.Client.Conventions.FieldNameConvention.GetFieldName(fieldListSelector) + "." + search.Client.Conventions.FieldNameConvention.GetFieldName(fieldListItemSelector); | |
View gist:5451390
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static ITypeSearch<TSource> FilterHits<TSource>(this ITypeSearch<TSource> search, Filter filter) | |
{ | |
return new Search<TSource, IQuery>(search, context => | |
{ | |
var filterToAdd = filter; | |
if (context.RequestBody.Filter.IsNotNull()) | |
{ | |
filterToAdd = filter & context.RequestBody.Filter; | |
} | |
context.RequestBody.Filter = filterToAdd; |
View gist:6699210
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.ajax | |
({ | |
type: "GET", | |
url: "https://server/_status", | |
dataType: 'jsonp' | |
}).done(function(data) { | |
for(indexName in data.indices) | |
{ | |
$('#indices').append('<div><span>' + indexName + '</span> <span>' + data.indices[indexName].docs.num_docs + '</span> <span>' + data.indices[indexName].index.primary_size +'</span></div>'); | |
} |
View gist:8647566
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// At query time add appropriate tags | |
using EPiServer.Find.Framework.Statistics; | |
client.Search<>() | |
... | |
.Track(new string[] { "mytag" }) | |
.GetResults() | |
// When fetching autocomplete/didyoumean/spellcheck through the REST endpoint |
View gist:9779858
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static ITypeSearch<TSource> ThenByScore<TSource>(this ITypeSearch<TSource> search) | |
{ | |
return new Search<TSource, IQuery>(search, context => | |
context.RequestBody.Sort.Add(new Sorting("_score"))); | |
} |
View gist:30391262cf166a07f451
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class NestedTermsFacetExtensions | |
{ | |
public static ITypeSearch<TSource> NestedTermsFacetFor<TSource, TEnumerable>( | |
this ITypeSearch<TSource> search, | |
Expression<Func<TSource, IEnumerable<TEnumerable>>> enumerableFieldSelector, Expression<Func<TEnumerable, string>> itemFieldSelector) | |
{ | |
return search.AddNestedTermsFacetFor(enumerableFieldSelector, itemFieldSelector, null); | |
} | |
public static ITypeSearch<TSource> NestedTermsFacetFor<TSource, TEnumerable>( |
View NestedFacetExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class NestedFacetExtensions | |
{ | |
// Allow passing Action<NestedTermsFacetRequest> facetRequestAction (in order to set for example Size on the request) | |
public static ITypeSearch<TSource> TermsFacetFor<TSource, TListItem> | |
(this ITypeSearch<TSource> search,Expression<Func<TSource, IEnumerable<TListItem>>> nestedFieldSelector, | |
Expression<Func<TListItem, string>> itemFieldSelector, | |
Expression<Func<TListItem, Filter>> filterExpression = null, | |
Action<NestedTermsFacetRequest> facetRequestAction = null) | |
{ | |
var facetFilter = NestedFilter.Create(search.Client.Conventions, nestedFieldSelector, filterExpression); |
View HighlightExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class HighlightExtensions | |
{ | |
public static IQueriedSearch<TSource, TExistingQuery> WithAttachmentHighlight<TSource, TExistingQuery>( | |
this IQueriedSearch<TSource, TExistingQuery> search, Action<FieldHighlightRequest> highlightAction = null) | |
where TExistingQuery : QueryStringQuery | |
{ | |
return new Search<TSource, TExistingQuery>(search, context => | |
{ | |
var fieldName = "*$$attachment"; | |
var request = new FieldHighlightRequest(fieldName); |
OlderNewer