Azure 搜索匹配同一对象的两个属性
Azure Search match against two properties of the same object
我想针对子集合中同一项目的两个属性进行查询匹配。
示例:
[
{
"name": "Person 1",
"contacts": [
{ "type": "email", "value": "person.1@xpto.org" },
{ "type": "phone", "value": "555-12345" },
]
}
]
我希望能够按 emails
进行搜索而不是包含 xpto.org
但是,
执行以下操作无效:
search.ismatchscoring('email','contacts/type,','full','all') and search.ismatchscoring('/.*xpto.org/','contacts/value,','full','all')
相反,它会考虑主对象上下文中的条件,如下所示的对象也会匹配:
[
{
"name": "Person 1",
"contacts": [
{ "type": "email", "value": "555-12345" },
{ "type": "phone", "value": "person.1@xpto.org" },
]
}
]
有什么办法可以解决这个问题而无需额外的字段来连接类型和值?
刚看到官方文档。目前不支持关联搜索:
This happens because each clause applies to all values of its field in
the entire document, so there's no concept of a "current sub-document
https://docs.microsoft.com/en-us/azure/search/search-howto-complex-data-types
和https://docs.microsoft.com/en-us/azure/search/search-query-understand-collection-filters
我实施的解决方案是为每种联系人类型创建不同的集合。
这样我就可以直接在电子邮件集合中进行搜索,而不需要相关搜索。它可能不是适用于所有情况的解决方案,但在这种情况下效果很好。
我想针对子集合中同一项目的两个属性进行查询匹配。
示例:
[
{
"name": "Person 1",
"contacts": [
{ "type": "email", "value": "person.1@xpto.org" },
{ "type": "phone", "value": "555-12345" },
]
}
]
我希望能够按 emails
进行搜索而不是包含 xpto.org
但是,
执行以下操作无效:
search.ismatchscoring('email','contacts/type,','full','all') and search.ismatchscoring('/.*xpto.org/','contacts/value,','full','all')
相反,它会考虑主对象上下文中的条件,如下所示的对象也会匹配:
[
{
"name": "Person 1",
"contacts": [
{ "type": "email", "value": "555-12345" },
{ "type": "phone", "value": "person.1@xpto.org" },
]
}
]
有什么办法可以解决这个问题而无需额外的字段来连接类型和值?
刚看到官方文档。目前不支持关联搜索:
This happens because each clause applies to all values of its field in the entire document, so there's no concept of a "current sub-document
https://docs.microsoft.com/en-us/azure/search/search-howto-complex-data-types
和https://docs.microsoft.com/en-us/azure/search/search-query-understand-collection-filters
我实施的解决方案是为每种联系人类型创建不同的集合。
这样我就可以直接在电子邮件集合中进行搜索,而不需要相关搜索。它可能不是适用于所有情况的解决方案,但在这种情况下效果很好。