【问题标题】:Filter for one attribute (array) for one of its value (json)过滤一个属性(数组)的值之一(json)
【发布时间】:2020-01-21 16:19:59
【问题描述】:

有以下记录

   {
      "name": "
 Festões Plástico, 12mt x 17cm - Festas Populares",
      "categories": [
        "Festas",
        "Casamentos",
        "Decorações"
      ],
      "hierarchicalCategories": {
        "lvl0": "Festas",
        "lvl1": "Festas > Casamentos",
        "lvl2": "Festas > Casamentos > Decorações"
      },
      "description": "",
      "brand": "Misterius",
      "price": 14.94,
      "stock": "Disponível",
      "prices": [
        {
          "value": 12,
          "type": "specificValue",
          "family": "fatos",
          "subfamily": "example"
        },
        {
          "value": 13,
          "type": "specificValue13",
          "family": "fatos13",
          "subfamily": "example13"
        },
        {
          "value": 14,
          "type": "specificValue14",
          "family": "fatos14",
          "subfamily": "example14"
        },
        {
          "value": 15,
          "type": "specificValue15",
          "family": "fatos15",
          "subfamily": "example15"
        },
        {
          "value": 16,
          "type": "specificValue16",
          "family": "fatos16",
          "subfamily": "example16"
        }
      ],
      "color": [
        {
          "name": "Amarelo",
          "label": "Amarelo,#FFFF00",
          "hexa": "#FFFF00"
        },
        {
          "name": "Azul",
          "label": "Azul,#0000FF",
          "hexa": "#0000FF"
        },
        {
          "name": "Branco",
          "label": "Branco,#FFFFFF",
          "hexa": "#FFFFFF"
        },
        {
          "name": "Laranja",
          "label": "Laranja,#FFA500",
          "hexa": "#FFA500"
        },
        {
          "name": "Verde Escuro",
          "label": "Verde Escuro,#006400",
          "hexa": "#006400"
        },
        {
          "name": "Vermelho",
          "label": "Vermelho,#FF0000",
          "hexa": "#FF0000"
        }
      ],
      "specialcategorie": "",
      "reference": "3546",
      "rating": 0,
      "free_shipping": false,
      "popularity": 0,
      "objectID": "30"
    }

现在通过搜索“Festas Populares”将返回记录及其属性,是否也可以将一个属性数组过滤为“价格”以仅返回一个 json。例如 "prices.type"="specificValue14" 和 "family"="fatos14" 和 "family"="fatos" 和 "subfamily"="example"

{
“value”: 14,
“type”: “specificValue14”,
“family”: “fatos14”,
“subfamily”: “example14”
}

记录回报是:

 {
          "name": "
 Festões Plástico, 12mt x 17cm - Festas Populares",
          "categories": [
            "Festas",
            "Casamentos",
            "Decorações"
          ],
          "hierarchicalCategories": {
            "lvl0": "Festas",
            "lvl1": "Festas > Casamentos",
            "lvl2": "Festas > Casamentos > Decorações"
          },
          "description": "",
          "brand": "Misterius",
          "price": 14.94,
          "stock": "Disponível",
          "prices": [
            {
              "value": 14,
              "type": "specificValue14",
              "family": "fatos14",
              "subfamily": "example14"
            }
          ],
          "color": [
            {
              "name": "Amarelo",
              "label": "Amarelo,#FFFF00",
              "hexa": "#FFFF00"
            },
            {
              "name": "Azul",
              "label": "Azul,#0000FF",
              "hexa": "#0000FF"
            },
            {
              "name": "Branco",
              "label": "Branco,#FFFFFF",
              "hexa": "#FFFFFF"
            },
            {
              "name": "Laranja",
              "label": "Laranja,#FFA500",
              "hexa": "#FFA500"
            },
            {
              "name": "Verde Escuro",
              "label": "Verde Escuro,#006400",
              "hexa": "#006400"
            },
            {
              "name": "Vermelho",
              "label": "Vermelho,#FF0000",
              "hexa": "#FF0000"
            }
          ],
          "specialcategorie": "",
          "reference": "3546",
          "rating": 0,
          "free_shipping": false,
          "popularity": 0,
          "objectID": "30"
        }

对于某些情况,产品可以关联多个价格,对于特定用户,或者某天有活动提供折扣等,因此在这种情况下希望过滤与产品/记录关联的价格。

【问题讨论】:

    标签: algolia instantsearch.js


    【解决方案1】:

    不,这对于 Algolia 是不可能的。记录总是以attributesToRetrieve 中指定的属性返回。这些属性全部返回。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-02-11
      • 2015-09-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-11-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多