按筛选后的嵌套属性划分的Azure Search Complex类型构面基于找到的对象 [英] Azure Search Complex types faceting by filtered nested properties is based on found objects

查看:43
本文介绍了按筛选后的嵌套属性划分的Azure Search Complex类型构面基于找到的对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Azure搜索复杂类型预览API(2017-11-11-Preview)来按复杂类型进行筛选/构面.我所有的过滤器和构面都是在嵌套类型(不是根类型)的属性上创建的,看起来它们没有在正确的嵌套级别上组合,而仅通过文档根目录组合.例如,我在搜索索引中有下一个文档

I'm using Azure Search complex types preview API (2017-11-11-Preview) for filtering/faceting by complex types. All of my filters and facets are creating on properties in nested type (not root type) and looks like they are not combining on the right nesting level but only through document root. For example, I have the next document in the search index

{ 
  apartmentComplexId: "1",
  apartmentTypes: [
    { 
      bedroomCount: 1,
      bathroomCount: 2
    },
    { 
      bedroomCount: 2,
      bathroomCount: 3
    }
  ]
}

apartmentTypes.bedroomCount apartmentTypes.bathroomCount 已刻面并已过滤.数据集的构面结果将返回

apartmentTypes.bedroomCount and apartmentTypes.bathroomCount are faceted and filtered. Facet result for dataset will return

{
  "apartmentTypes/bedroomCount": [
    {
      "count": 1,
      "value": 1
    },
    {
      "count": 1,
      "value": 2
    }
  ],
  "apartmentTypes/bathroomCount": [
    {
      "count": 1,
      "value": 2
    },
    {
      "count": 1,
      "value": 3
    }
  ]
}

当我执行下一个查询时:

When I'm executing the next query:

$filter=apartmentTypes/any(x: x/bedroomCount eq 1)&facet=apartmentTypes/bathroomCount

作为响应的

我的facet集合包含bathroomCount的所有两个可能的facet值-2和3,每个值均为1.

my facets collection in response contains all two possible facet values for bathroomCount - 2 and 3 with value of 1 for each of them.

{
  "apartmentTypes/bathroomCount": [
    {
      "count": 1,
      "value": 2
    },
    {
      "count": 1,
      "value": 3
    }
  ]
}

下一步,我尝试在更具体的过滤器中使用构面数据

By the next step I'm trying to use facet data in my more concrete filter

$filter=apartmentTypes/any(x: x/bedroomCount eq 1 and x/bathroomCount eq 3)

糟糕,我的结果集为空.

Oops, I've got empty resultset.

我了解更正确的过滤器字符串应类似于

I understand that more correct filter string should be something like

$filter=apartmentTypes/any(x: x/bedroomCount) and values/any(x: x/bathroomcount eq 3)

但是我需要完全像这样的功能-找到的实体应在其集合中包含具有所有多面结果的项目.

but I need the functionality exactly like this - found entity should contain the item in its collection with all the faceted results.

推荐答案

紧缩和过滤都在文档范围内进行,而不是在复杂集合中的项目范围内进行(尽管您可以在复杂集合上编写相关过滤器,例如在您的第一个示例中).这是设计使然.

Faceting and filtering both operate at document-scope, not at the scope of items in a complex collection (although you can write correlated filters on a complex collection, as in your first example). This is by design.

在您的情况下,这导致用户期望与系统行为不匹配.作为用户,如果我单击描述公寓的各个方面,那么我自然会假设过滤也在公寓上进行,但实际上是在公寓复合物上进行.这就是为什么您的示例中的空结果集如此不直观的原因.

In your scenario, this is leading to a mismatch of user expectations with the system's behavior. As a user, if I'm clicking through facets describing apartments, I'm naturally going to assume that filtering is happening on apartments too, but it's actually happening on apartment complexes. This is why the empty resultset in your example is so unintuitive.

我建议根据用户的浏览方式为索引建模.假设用户通常搜索的是公寓,而不是公寓,请尝试将 apartmentType 设置为文档类型,并在必要时对公寓的信息进行非规范化.

I would recommend modeling your indexes according to how users will navigate. Assuming users typically search for apartments, not apartment complexes, try making apartmentType the document type and denormalize the apartment complex information if necessary.

同时,请考虑在用户语音上创建一个项目,以帮助我们优先考虑增加对相关方面的支持,而不是复杂集合.

In the meantime, please consider creating an item on User Voice to help us prioritize adding support for correlated facets over complex collections.

这篇关于按筛选后的嵌套属性划分的Azure Search Complex类型构面基于找到的对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆