代码之家  ›  专栏  ›  技术社区  ›  Simple Code

如何使用Nest Elasticsearch通过文档计数提升建议?

  •  0
  • Simple Code  · 技术社区  · 6 年前

    我有 产品 index和I具有以下属性:

    public class ProductType
    {
        public Guid Id { get; set; }
    
        public string Title { get; set; }
    
        public string Description{ get; set; }
    
        public IList<string> ProductAttributes { get; set; }
    
        public CompletionField Suggest { get; set; }
    }
    

    productType.Suggest= new CompletionField
            {
                Input =product.ProductAttributes.Select(x => x).ToList(),
                Weight = 10
            };
    

    附言:

    以下是我用于自动完成的查询:

    GET product/producttype/_search
    {
      "suggest": {
        "attribute-suggestions": {
          "prefix": "c",
          "completion": {
            "field": "suggest"
          }
        }
      },
      "_source": {
        "includes": [
          "id",
          "title",
          "productAttributes"
        ]
      }
    }
    

    编辑:

    中央处理器 照相机 在5个产品中,我希望上面的查询能够提高摄像头的Cpu性能。

    0 回复  |  直到 6 年前