search stuff

This commit is contained in:
2022-02-05 01:52:48 +01:00
parent 17363ee620
commit 3030d8706f
7 changed files with 76 additions and 8 deletions
+11 -3
View File
@@ -8,13 +8,14 @@ public class SearchIndexMap
internal string _Icon;
protected string _group;
protected string[] _fields;
protected float _boost = 0;
protected Func<ZeroEntity, SearchResult, IZeroOptions, Task> _modify;
const string mapTemplate = @"map('{collection}', function (x) {
return {
Id: x.Id,
Group: '{group}',
Name: x.Name,
Name: boost(x.Name, {boost}),
IsActive: x.IsActive,
Fields: [{fields}]
};
@@ -33,7 +34,8 @@ public class SearchIndexMap
{
{ "collection", store.Conventions.GetCollectionName(Type) },
{ "group", _group },
{ "fields", BuildFieldArray(_fields) }
{ "fields", BuildFieldArray(_fields) },
{ "boost", _boost.ToString() }
});
}
@@ -44,7 +46,7 @@ public class SearchIndexMap
return String.Empty;
}
return "x." + String.Join(", x.", fields);
return String.Join(", ", fields.Select(x => $"x.{x}")); //$"boost(x.{x}, {_boost})"));
}
internal bool CanModify(Type type)
@@ -109,4 +111,10 @@ public class SearchIndexMap<T> : SearchIndexMap where T : ZeroEntity
_fields = fieldNames;
return this;
}
public SearchIndexMap<T> Boost(float boostValue)
{
_boost = boostValue;
return this;
}
}