100 search results
This commit is contained in:
@@ -101,7 +101,7 @@
|
||||
return;
|
||||
}
|
||||
|
||||
const result = await api.query(this.query, { pageSize: 20 });
|
||||
const result = await api.query(this.query, { pageSize: 100 });
|
||||
|
||||
if (result.data)
|
||||
{
|
||||
|
||||
@@ -36,9 +36,9 @@ internal class ZeroPageModule : ZeroModule
|
||||
|
||||
services.Configure<ZeroSearchOptions>(opts =>
|
||||
{
|
||||
opts.Map<Page>().Display((x, res, opts) =>
|
||||
opts.Map<Page>().Display((x, res, ctx) =>
|
||||
{
|
||||
FlavorConfig flavor = opts.For<FlavorOptions>().Get<Page>(x.Flavor);
|
||||
FlavorConfig flavor = ctx.Options.For<FlavorOptions>().Get<Page>(x.Flavor);
|
||||
if (flavor != null)
|
||||
{
|
||||
res.Icon = flavor.Icon;
|
||||
|
||||
@@ -9,7 +9,7 @@ public class SearchIndexMap
|
||||
protected string _group;
|
||||
protected string[] _fields;
|
||||
protected float _boost = 0;
|
||||
protected Func<ZeroEntity, SearchResult, IZeroOptions, Task> _modify;
|
||||
protected Func<ZeroEntity, SearchResult, IZeroContext, Task> _modify;
|
||||
|
||||
const string mapTemplate = @"map('{collection}', function (x) {
|
||||
return {
|
||||
@@ -54,11 +54,11 @@ public class SearchIndexMap
|
||||
return Type.IsAssignableFrom(type);
|
||||
}
|
||||
|
||||
internal async Task Modify(ZeroEntity entity, SearchResult result, IZeroOptions options)
|
||||
internal async Task Modify(ZeroEntity entity, SearchResult result, IZeroContext context)
|
||||
{
|
||||
if (_modify != null)
|
||||
{
|
||||
await _modify(entity, result, options);
|
||||
await _modify(entity, result, context);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -86,26 +86,26 @@ public class SearchIndexMap<T> : SearchIndexMap where T : ZeroEntity
|
||||
|
||||
public SearchIndexMap<T> Display(Func<T, SearchResult, Task> modify = null)
|
||||
{
|
||||
_modify = (x, res, opts) => modify?.Invoke(x as T, res);
|
||||
_modify = (x, res, ctx) => modify?.Invoke(x as T, res);
|
||||
return this;
|
||||
}
|
||||
|
||||
public SearchIndexMap<T> Display(Action<T, SearchResult, IZeroOptions> modify = null)
|
||||
public SearchIndexMap<T> Display(Func<T, SearchResult, IZeroContext, Task> modify = null)
|
||||
{
|
||||
_modify = (x, res, opts) =>
|
||||
_modify = (x, res, ctx) => modify?.Invoke(x as T, res, ctx);
|
||||
return this;
|
||||
}
|
||||
|
||||
public SearchIndexMap<T> Display(Action<T, SearchResult, IZeroContext> modify = null)
|
||||
{
|
||||
_modify = (x, res, ctx) =>
|
||||
{
|
||||
modify?.Invoke(x as T, res, opts);
|
||||
modify?.Invoke(x as T, res, ctx);
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
return this;
|
||||
}
|
||||
|
||||
public SearchIndexMap<T> Display(Func<T, SearchResult, IZeroOptions, Task> modify = null)
|
||||
{
|
||||
_modify = (x, res, opts) => modify?.Invoke(x as T, res, opts);
|
||||
return this;
|
||||
}
|
||||
|
||||
public SearchIndexMap<T> Fields(params string[] fieldNames)
|
||||
{
|
||||
_fields = fieldNames;
|
||||
|
||||
@@ -9,12 +9,15 @@ public class SearchService : ISearchService
|
||||
protected IZeroStore Store { get; private set; }
|
||||
|
||||
protected IZeroOptions Options { get; private set; }
|
||||
|
||||
protected IZeroContext Context { get; private set; }
|
||||
|
||||
|
||||
public SearchService(IZeroStore store, IZeroOptions options)
|
||||
public SearchService(IZeroStore store, IZeroOptions options, IZeroContext context)
|
||||
{
|
||||
Store = store;
|
||||
Options = options;
|
||||
Context = context;
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +56,7 @@ public class SearchService : ISearchService
|
||||
Url = "/"
|
||||
};
|
||||
|
||||
await map.Modify(result, searchResult, Options);
|
||||
await map.Modify(result, searchResult, Context);
|
||||
|
||||
items.Add(searchResult);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user