我正在尝试在我的网上商店中实现弹性搜索,但在使用过滤器时遇到了一些麻烦。过滤是动态完成的。
例子:
我首先展示所有被索引的产品。所以没有应用过滤器。访问者可以选择自己的过滤器,例如:颜色、尺寸、品牌、类型、类别......
但我现在不知道如何使用 elasticsearch 和 NEST 构建搜索结果。
这是我没有过滤的解决方案:
var query = ElasticClient.Search<Product>(s => s
.From(from)
.Size(size)
);
我还有另一个关于索引集合<> 或列表<> 的问题。我不得不在这些集合上使用 JsonIgnore。我也可以索引这些吗?
这是我的课:
/// <summary>
/// Represents a product
/// </summary>
public partial class Product {
private ICollection<ProductCategory> _productCategories;
private ICollection<ProductManufacturer> _productManufacturers;
private ICollection<ProductPicture> _productPictures;
/// <summary>
/// Gets or sets the name
/// </summary>
public virtual string Name { get; set; }
/// <summary>
/// Gets or sets the short description
/// </summary>
public virtual string ShortDescription { get; set; }
/// <summary>
/// Gets or sets a value indicating whether the entity is published
/// </summary>
public virtual bool Published { get; set; }
/// <summary>
/// Gets or sets a value indicating whether the entity has been deleted
/// </summary>
public virtual bool Deleted { get; set; }
/// <summary>
/// Gets or sets the date and time of product creation
/// </summary>
public virtual DateTime CreatedOnUtc { get; set; }
/// <summary>
/// Gets or sets the date and time of product update
/// </summary>
public virtual DateTime UpdatedOnUtc { get; set; }
/// <summary>
/// Gets or sets the collection of ProductCategory
/// </summary>
[JsonIgnore] /* added - wesley */
public virtual ICollection<ProductCategory> ProductCategories
{
get { return _productCategories ?? (_productCategories = new List<ProductCategory>()); }
protected set { _productCategories = value; }
}
/// <summary>
/// Gets or sets the collection of ProductManufacturer
/// </summary>
[JsonIgnore] /* added - wesley */
public virtual ICollection<ProductManufacturer> ProductManufacturers
{
get { return _productManufacturers ?? (_productManufacturers = new List<ProductManufacturer>()); }
protected set { _productManufacturers = value; }
}
/// <summary>
/// Gets or sets the collection of ProductPicture
/// </summary>
[JsonIgnore] /* added - wesley */
public virtual ICollection<ProductPicture> ProductPictures
{
get { return _productPictures ?? (_productPictures = new List<ProductPicture>()); }
protected set { _productPictures = value; }
}
}
有人可以帮助我吗?