Azure搜索:按动态数据排序 [英] Azure Search: Order by dynamic data

查看:74
本文介绍了Azure搜索:按动态数据排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Azure搜索索引,该索引由可以多次出现在多个区域中的文档组成.例如,Document1Region1中出现5次,在Region2中出现20次. Document2Region1中具有54次出现,在Region3中具有10次出现. Document3Region3中有10次出现.我们希望使用Azure搜索进行搜索和建议,但顺序基于区域上出现的次数.例如,从Region1中的用户搜索Document应该以Document2Document1Document3的顺序返回,因为Document2在该区域中有54次出现,而Document1有5次出现且Document3没有任何内容.

I have an Azure Search index composed of documents that can "occur" in multiple regions any number of times. For example Document1 has 5 occurrences in Region1, 20 occurrences in Region2. Document2 has 54 occurrences in Region1, and 10 occurrences in Region3. Document3 has 10 occurrences in Region3. We want to use Azure Search for searching and suggestions, but base the order on number of occurrences on a region. For example the search for Document from a user in Region1 should return in the order Document2, Document1, Document3 because Document2 has 54 occurrences in that region, while Document1 has 5 occurrences and Document3 has none.

[
  { 'name': 'Document1', 'regions': ['Region1|5', 'Region2|20'] },
  { 'name': 'Document2', 'regions': ['Region1|54', 'Region3|10'] },
  { 'name': 'Document3', 'regions': ['Region3|10'] }
]

我很难弄清楚如何构造索引,或者甚至可以通过Azure搜索来解决.请注意,区域数可能为数十万.我可以更改中心点的区域并改用地理空间功能,但是我仍然看不到如何放置数据或查询数据.

I'm having a hard time figuring out how to structure the index or if it is even possible with Azure Search. Please note that the number of regions is potentially in the hundreds of thousands. I am ok with changing regions for center points and use geospatial functions instead, but I still don't see how to lay the data or query it.

构造索引的最佳方法是什么?如何使查询成为可能?

What is the best way to structure the index and how would one make the query possible?

推荐答案

tl; dr-根据我的一些假设,可能有个解决方案.请继续阅读,如果可能的话,请尝试围绕我的假设提供一些验证,以便我给出更好的答案(如果存在这样的答案).

tl;dr - There might be a solution for you based on some assumptions I have. Please read on, and if possible try to provide some validations around my assumptions for me to give a better answer (if such an answer exists).

不幸的是,Azure搜索没有适用于您的方案的现成方法.但是,可能有一种解决方法-您可以尝试将文档构造为看起来像['Region1', 'Region1',...., 'Region2', 'Region2', ...],而不是使用region集合,例如['Region1|5', 'Region2|20'](也就是说,使该集合包含 n Region1的em>元素和Region2 m 元素,在您的情况下, n = 5, m = 10.

Unfortunately, Azure search doesn't have an out-of-the box approach for your scenario. There might be a work around however - instead of the regions collection being something like ['Region1|5', 'Region2|20'], you could try to structure the document such that it appears to be ['Region1', 'Region1',...., 'Region2', 'Region2', ...] (that is, make the collection contain n elements of Region1 and m elements of Region2 where in your case n = 5 and m = 10.

然后,您应该可以仅使用用户来源的 Region 进行搜索,并且我相信应该根据哪个文档的收集列(regions)包含更多次出现的结果来对结果进行排序特定的查询区域.

Then you should simply be able to search using the Region that the user originates from and I believe the results should be ordered based on which document's collection column (regions) contains more occurrences of the particular queried region.

这种方法可以通过两种方式为您提供帮助:

This approach helps you in 2 ways:

  1. 您可以尝试将每个区域添加为搜索索引中的一列,并使用一些查询来获得所需的结果.但是,由于您提到的区域可能有数十万,因此它与我们的
  1. You could try adding each region as a column in the search index and use some queries to get the kind of result you want. However, since you mention there might be hundreds of thousands of such regions, it might not work well with our service limits. If however that's not the case, I highly recommend adding each region as a column, so that you can query/order by the column value.
  2. With the replication of the string approach, you can have arbitrarily large collections as I believe Azure search does not have any limitations with regard to the number of elements in a collection. Also the nice thing here is, if your document will have a sparse number of regions (i.e., you may have 100s of 1000s of regions, but any given document will only have few regions enumerated), you should be able to achieve what you want. If that's not the case however, this approach might not be super nice/efficient and might even be painful for you to manage.

此外,仅供参考,我建议您看一下

Also, just FYI I'd recommend taking a look at the scoring profiles feature and especially the tag function to see if that might in any way be useful to you.

这篇关于Azure搜索:按动态数据排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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