【问题标题】:Sort: Get the author's documents before other documents排序:在其他文档之前获取作者的文档
【发布时间】:2016-10-13 20:48:42
【问题描述】:

我有以下问题: 有没有办法在排序时使用特定的常量值作为决胜局?

这是我的例子:

假设索引结构:

{
     title: "Title",
     author: "Name of author"
}

假设我们有以下搜索查询:http://example.cloudsearch.amazonaws.com/2013-01-01/search?q=test&return=_all_fields%2C_score&sort=_score%20desc

问题是,如果有 10 个具有相同标题“测试”的文档,它们的分数都相同,现在我想对这些文档进行排序并将当前作者创建的文档放在首位。我尝试过使用表达式,但似乎无法让它工作,这就是我尝试过的:

http://example.cloudsearch.amazonaws.com/2013-01-01/search?q=test&return=_all_fields%2C_score&sort=_score%20desc,isauthor%20desc&expr.isauthor=(author%3D%3D%id) 但是我怀疑 cloudsearch 会接受这一点。有什么办法可以通过搜索字符串解决这个问题,还是我需要索引数字作者标识符之类的东西?

【问题讨论】:

    标签: amazon-web-services amazon-cloudsearch


    【解决方案1】:

    如果其他人有兴趣,这就是我最终要做的。

    创建了一个新的索引字段:author_identifier,我用它来索引每个用户的唯一整数标识符(这是另一个挑战,因为用户 ID 是 GUID,所以我必须将它们与数字相关联。

    然后我使用了一个排序表达式:http://example.cloudsearch.amazonaws.com/2013-01-01/search?q=test&return=_all_fields%2C_score&sort=_score%20desc,isauthor%20desc&expr.isauthor=(author_identifer%3D%3D%mappedid)

    这不是一个理想的解决方案,但我猜总比没有好。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-01-10
      • 1970-01-01
      • 1970-01-01
      • 2015-12-23
      • 2012-12-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多