Azure搜索如何在复杂类型集合中获取一个特定项目 [英] Azure Search how to get one specific item in a complex type collection

查看:47
本文介绍了Azure搜索如何在复杂类型集合中获取一个特定项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个歌曲索引,每首歌曲都有一组客户.如果我过滤包含特定客户的歌曲效果很好,但是我得到的结果是该歌曲的所有客户.我只需要在集合中过滤的客户那里就可以得到这首歌.

I have an index for songs and each song have a collection of customers. If I filter songs that contains a specific customer works great, but I get in the result all the customers for the song. I would need to get the song with only the customer I'm filtering in the collection.

我的索引类似于:

{
   SongId: 1,
   Title: "My song",
   Artist: "Artist",
   Customers: [
   {
      CustomerId: 1,
      ...more customer data
   }
   {
      CustomerId: 2,
      ...more customer data
   }
   ]
}

我需要按标题过滤歌曲,并且仅获取客户1的数据,或者如果客户1不在该歌曲的集合中,则仅获取客户1的数据.有可能吗?

I need to get the song filtering by title and only get the customer's 1 data or no customer if the customer 1 is not in the collection for that song. Is that possible?

推荐答案

今天这不可能.您必须在客户端过滤掉复杂的集合元素.

This is not possible today. You'd have to filter out the complex collection elements on the client-side.

此外,您没有在问题中提到这一点,但似乎从歌曲到客户的关系的基数可能很高.在这种情况下,您应该考虑使用其他数据模型,因为存在

Also, you didn't mention this in your question, but it seems the cardinality of the relationship from songs to customers could be quite high. If that's the case, you should consider a different data model, because there is a hard limit on the number of elements you can have in complex collections per document. Even without that limit, there are practical limits to complex collections, for example around document size and the inability to incrementally update them during indexing.

如果您的模型每首歌曲最多拥有几百个客户,则可能还不错,但是如果模型的成千上万个或更高,则应重新考虑您的设计.

If your model will have at most a few hundred customers per song, you're probably fine, but if it's in the thousands or higher, you should reconsider your design.

这篇关于Azure搜索如何在复杂类型集合中获取一个特定项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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