驱动SDK查询结果随机排序

时间:2015-04-21 06:24:33

标签: java google-drive-api

Google Drive SDK存在以下问题。

直到几天前,查询结果已经过排序"最后一次修改"。现在我似乎随机收到了结果,我不能再使用这个SDK了...我有超过400k的文件,我真的需要先通过最新的检索。当我从DocumentList API迁移到Drive SDk时,我确信这就是结果的排序方式(即使我们没有在SDK中设置特定排序的可能性)。

有没有办法接收排序的结果(按上次修改)?几周前我在Drive UI上报告了一个错误,因为他们按最后修改的UI排序不起作用......也许这两个是以某种方式相关的..

实施例: 对于这个查询(我添加了q param - 没有它就可以正常工作): https://www.googleapis.com/drive/v2/files?maxResults=1000&fields=items(createdDate%2CmodifiedDate%2ClastViewedByMeDate)&access_token=[my_access_token]&q=fullText%20contains%20%27expert%27

我收到了这个结果:

{
 "items": [
  {
   "createdDate": "2014-10-24T11:46:59.967Z",
   "modifiedDate": "2015-04-20T15:30:59.804Z",
   "lastViewedByMeDate": "2015-04-20T15:30:59.804Z"
  },
  {
   "createdDate": "2015-04-01T13:27:59.111Z",
   "modifiedDate": "2015-04-01T13:27:58.896Z",
   "lastViewedByMeDate": "2015-04-01T13:52:39.022Z"
  },
  {
   "createdDate": "2015-04-01T11:13:28.795Z",
   "modifiedDate": "2015-04-01T13:27:57.839Z",
   "lastViewedByMeDate": "2015-04-01T13:27:57.839Z"
  },
  {
   "createdDate": "2014-10-22T14:59:40.171Z",
   "modifiedDate": "2015-02-11T21:06:05.092Z",
   "lastViewedByMeDate": "2014-10-22T15:00:14.597Z"
  },
  {
   "createdDate": "2010-10-26T03:53:44.131Z",
   "modifiedDate": "2015-04-21T01:08:35.357Z",
   "lastViewedByMeDate": "2015-04-21T01:08:35.357Z"
  },
  {
   "createdDate": "2014-04-28T06:12:38.437Z",
   "modifiedDate": "2014-04-28T07:30:46.094Z",
   "lastViewedByMeDate": "2014-04-28T06:12:38.299Z"
  },
  {
   "createdDate": "2013-11-06T14:46:12.549Z",
   "modifiedDate": "2013-11-06T14:46:12.482Z",
   "lastViewedByMeDate": "2013-11-06T14:46:12.482Z"
  },
  {
   "createdDate": "2011-10-18T14:12:35.599Z",
   "modifiedDate": "2012-06-13T15:40:13.057Z",
   "lastViewedByMeDate": "2012-06-22T13:05:45.158Z"
  },
  {
   "createdDate": "2012-02-22T22:24:09.600Z",
   "modifiedDate": "2012-02-22T22:24:09.600Z",
   "lastViewedByMeDate": "2012-02-22T22:52:36.858Z"
  },
  {
   "createdDate": "2011-07-07T14:09:15.238Z",
   "modifiedDate": "2011-07-07T14:09:15.928Z",
   "lastViewedByMeDate": "2011-07-07T14:09:15.238Z"
  },
  {
   "createdDate": "2015-04-18T22:46:59.101Z",
   "modifiedDate": "2015-04-18T22:46:59.101Z"
  },
  {
   "createdDate": "2015-04-02T01:52:16.404Z",
   "modifiedDate": "2015-04-02T01:52:16.404Z"
  },
  {
   "createdDate": "2015-04-09T00:07:00.497Z",
   "modifiedDate": "2015-04-09T00:07:00.497Z"
  },
  {
   "createdDate": "2015-04-01T14:16:06.853Z",
   "modifiedDate": "2015-04-01T15:30:51.873Z",
   "lastViewedByMeDate": "2015-04-01T15:30:51.873Z"
  },
  {
   "createdDate": "2015-03-31T10:59:21.475Z",
   "modifiedDate": "2015-03-31T15:30:14.912Z",
   "lastViewedByMeDate": "2015-03-31T15:30:14.912Z"
  },
  {
   "createdDate": "2015-03-31T11:00:26.907Z",
   "modifiedDate": "2015-03-31T15:30:13.887Z",
   "lastViewedByMeDate": "2015-03-31T15:30:13.887Z"
  },
  {
   "createdDate": "2015-03-24T12:09:05.989Z",
   "modifiedDate": "2015-03-24T16:31:22.397Z",
   "lastViewedByMeDate": "2015-03-24T16:31:22.397Z"
  },
  {
   "createdDate": "2015-03-24T12:08:06.496Z",
   "modifiedDate": "2015-03-24T16:31:23.532Z",
   "lastViewedByMeDate": "2015-03-24T16:31:23.532Z"
  },
  {
   "createdDate": "2015-03-24T12:07:06.766Z",
   "modifiedDate": "2015-03-24T16:31:24.557Z",
   "lastViewedByMeDate": "2015-03-24T16:31:24.557Z"
  },
  {
   "createdDate": "2015-04-15T01:23:10.561Z",
   "modifiedDate": "2015-04-15T01:23:10.561Z"
  },
  {
   "createdDate": "2015-03-28T02:32:46.061Z",
   "modifiedDate": "2015-03-28T02:32:46.061Z"
  },
  {
   "createdDate": "2015-03-28T02:33:52.753Z",
   "modifiedDate": "2015-03-28T02:33:52.753Z"
  },
  {
   "createdDate": "2015-03-28T02:34:21.426Z",
   "modifiedDate": "2015-03-28T02:34:21.426Z"
  },
  {
   "createdDate": "2015-03-29T00:03:32.451Z",
   "modifiedDate": "2015-03-29T00:03:32.451Z"
  },
  {
   "createdDate": "2015-03-25T02:31:31.270Z",
   "modifiedDate": "2015-03-25T02:31:31.270Z"
  },
  {
   "createdDate": "2011-03-05T12:03:40.150Z",
   "modifiedDate": "2011-03-05T12:03:40.445Z"
  },
  {
   "createdDate": "2015-04-11T01:10:00.930Z",
   "modifiedDate": "2015-04-11T01:10:00.930Z"
  },
  {
   "createdDate": "2015-04-15T01:22:48.385Z",
   "modifiedDate": "2015-04-15T01:22:48.385Z"
  },
  {
   "createdDate": "2015-04-11T22:32:04.150Z",
   "modifiedDate": "2015-04-11T22:32:04.150Z"
  },
  {
   "createdDate": "2015-04-04T23:33:14.835Z",
   "modifiedDate": "2015-04-04T23:33:14.835Z"
  },
  {
   "createdDate": "2012-05-06T02:38:21.947Z",
   "modifiedDate": "2010-05-10T09:56:04.344Z",
   "lastViewedByMeDate": "2010-05-10T09:56:04.378Z"
  },
  {
   "createdDate": "2012-02-24T16:10:52.238Z",
   "modifiedDate": "2012-02-24T16:10:52.238Z"
  },
  {
   "createdDate": "2013-06-20T09:04:08.899Z",
   "modifiedDate": "2013-06-20T15:30:15.869Z",
   "lastViewedByMeDate": "2013-06-20T09:04:06.378Z"
  },
  {
   "createdDate": "2015-03-21T02:39:01.691Z",
   "modifiedDate": "2015-03-21T02:39:01.691Z"
  },
  {
   "createdDate": "2015-03-25T02:32:50.688Z",
   "modifiedDate": "2015-03-25T02:32:50.688Z"
  },
  {
   "createdDate": "2012-02-24T15:33:20.376Z",
   "modifiedDate": "2012-02-24T15:33:20.376Z"
  },
  {
   "createdDate": "2015-04-07T01:28:06.075Z",
   "modifiedDate": "2015-04-07T01:28:06.075Z"
  },
  {
   "createdDate": "2015-04-21T01:32:46.368Z",
   "modifiedDate": "2015-04-21T01:32:46.368Z"
  },
  {
   "createdDate": "2015-03-26T02:34:53.860Z",
   "modifiedDate": "2015-03-26T02:34:53.860Z"
  },
  {
   "createdDate": "2015-03-24T02:36:05.213Z",
   "modifiedDate": "2015-03-24T02:36:05.213Z"
  },
  {
   "createdDate": "2015-03-26T02:35:07.290Z",
   "modifiedDate": "2015-03-26T02:35:07.290Z"
  },
  {
   "createdDate": "2015-04-01T01:39:17.195Z",
   "modifiedDate": "2015-04-01T01:39:17.195Z"
  },
  {
   "createdDate": "2015-03-25T02:32:17.868Z",
   "modifiedDate": "2015-03-25T02:32:17.868Z"
  },
  {
   "createdDate": "2015-03-31T01:33:18.988Z",
   "modifiedDate": "2015-03-31T01:33:18.988Z"
  },
  {
   "createdDate": "2015-04-09T01:39:16.710Z",
   "modifiedDate": "2015-04-09T01:39:16.710Z"
  },
  {
   "createdDate": "2015-03-24T02:37:05.567Z",
   "modifiedDate": "2015-03-24T02:37:05.567Z"
  },
  {
   "createdDate": "2015-04-01T01:38:38.577Z",
   "modifiedDate": "2015-04-01T01:38:38.577Z"
  },
  {
   "createdDate": "2012-02-24T16:02:27.075Z",
   "modifiedDate": "2012-02-24T16:02:27.075Z"
  },
  {
   "createdDate": "2015-03-29T00:04:18.833Z",
   "modifiedDate": "2015-03-29T00:04:18.833Z"
  },
  {
   "createdDate": "2015-04-01T00:06:32.153Z",
   "modifiedDate": "2015-04-01T00:06:32.153Z"
  },
  {
   "createdDate": "2015-03-25T02:31:41.763Z",
   "modifiedDate": "2015-03-25T02:31:41.763Z"
  },
  {
   "createdDate": "2011-04-30T20:18:25.783Z",
   "modifiedDate": "2011-04-30T20:18:40.005Z",
   "lastViewedByMeDate": "2011-04-30T20:19:23.444Z"
  },
  {
   "createdDate": "2015-04-17T01:27:50.396Z",
   "modifiedDate": "2015-04-17T01:27:50.396Z"
  },
  {
   "createdDate": "2015-04-04T01:31:47.567Z",
   "modifiedDate": "2015-04-04T01:31:47.567Z"
  },
  {
   "createdDate": "2015-04-21T01:33:37.666Z",
   "modifiedDate": "2015-04-21T01:33:37.666Z"
  },
  {
   "createdDate": "2015-04-01T22:41:39.802Z",
   "modifiedDate": "2015-04-01T22:41:39.802Z"
  },
  {
   "createdDate": "2011-03-04T15:57:55.272Z",
   "modifiedDate": "2011-03-04T15:57:55.913Z"
  },
  {
   "createdDate": "2012-02-24T15:00:16.349Z",
   "modifiedDate": "2012-02-24T15:00:16.349Z"
  },
  {
   "createdDate": "2015-04-02T01:52:21.717Z",
   "modifiedDate": "2015-04-02T01:52:21.717Z"
  },
  {
   "createdDate": "2015-04-08T01:32:45.011Z",
   "modifiedDate": "2015-04-08T01:32:45.011Z"
  },
  {
   "createdDate": "2015-04-18T01:37:05.209Z",
   "modifiedDate": "2015-04-18T01:37:05.209Z"
  },
  {
   "createdDate": "2015-03-22T00:05:45.414Z",
   "modifiedDate": "2015-03-22T00:05:45.414Z"
  },
  {
   "createdDate": "2015-04-17T01:26:34.855Z",
   "modifiedDate": "2015-04-17T01:26:34.855Z"
  },
  {
   "createdDate": "2015-04-21T01:33:03.887Z",
   "modifiedDate": "2015-04-21T01:33:03.887Z"
  },
  {
   "createdDate": "2015-04-16T01:20:52.755Z",
   "modifiedDate": "2015-04-16T01:20:52.755Z"
  },
  {
   "createdDate": "2015-03-26T01:11:02.164Z",
   "modifiedDate": "2015-03-26T01:11:02.164Z"
  },
  {
   "createdDate": "2015-03-21T02:39:35.748Z",
   "modifiedDate": "2015-03-21T02:39:35.748Z"
  },
  {
   "createdDate": "2015-04-02T14:52:24.352Z",
   "modifiedDate": "2015-04-02T15:30:06.196Z",
   "lastViewedByMeDate": "2015-04-02T15:30:06.196Z"
  },
  {
   "createdDate": "2015-04-15T01:22:26.547Z",
   "modifiedDate": "2015-04-15T01:22:26.547Z"
  },
  {
   "createdDate": "2015-03-21T02:38:35.937Z",
   "modifiedDate": "2015-03-21T02:38:35.937Z"
  },
  {
   "createdDate": "2015-03-25T02:33:54.446Z",
   "modifiedDate": "2015-03-25T02:33:54.446Z"
  },
  {
   "createdDate": "2015-03-21T02:38:07.188Z",
   "modifiedDate": "2015-03-21T02:38:07.188Z"
  },
  {
   "createdDate": "2015-04-15T01:22:22.159Z",
   "modifiedDate": "2015-04-15T01:22:22.159Z"
  },
  {
   "createdDate": "2012-02-24T16:06:33.144Z",
   "modifiedDate": "2012-02-24T16:06:33.144Z"
  },
  {
   "createdDate": "2012-02-24T15:43:22.463Z",
   "modifiedDate": "2012-02-24T15:43:22.463Z"
  },
  {
   "createdDate": "2015-03-27T02:31:42.703Z",
   "modifiedDate": "2015-03-27T02:31:42.703Z"
  },
  {
   "createdDate": "2015-03-31T01:33:03.757Z",
   "modifiedDate": "2015-03-31T01:33:03.757Z"
  },
  {
   "createdDate": "2012-02-24T15:43:37.716Z",
   "modifiedDate": "2012-02-24T15:43:37.716Z"
  },
  {
   "createdDate": "2015-03-21T02:39:00.688Z",
   "modifiedDate": "2015-03-21T02:39:00.688Z"
  },
  {
   "createdDate": "2015-04-09T01:39:29.141Z",
   "modifiedDate": "2015-04-09T01:39:29.141Z"
  },
  {
   "createdDate": "2015-03-31T00:08:58.988Z",
   "modifiedDate": "2015-03-31T00:08:58.988Z"
  },
  {
   "createdDate": "2015-04-11T00:08:05.753Z",
   "modifiedDate": "2015-04-11T00:08:05.753Z"
  },
  {
   "createdDate": "2012-02-24T15:51:13.353Z",
   "modifiedDate": "2012-02-24T15:51:13.353Z"
  },
  {
   "createdDate": "2012-11-05T08:10:05.136Z",
   "modifiedDate": "2012-11-05T15:30:21.255Z",
   "lastViewedByMeDate": "2012-11-05T08:10:05.136Z"
  },
  {
   "createdDate": "2015-04-04T01:31:32.870Z",
   "modifiedDate": "2015-04-04T01:31:32.870Z"
  },
  {
   "createdDate": "2012-02-24T15:58:33.360Z",
   "modifiedDate": "2012-02-24T15:58:33.360Z"
  },
  {
   "createdDate": "2015-04-17T01:27:57.242Z",
   "modifiedDate": "2015-04-17T01:27:57.242Z"
  },
  {
   "createdDate": "2015-04-08T01:33:17.158Z",
   "modifiedDate": "2015-04-08T01:33:17.158Z"
  },
  {
   "createdDate": "2015-03-29T00:07:04.866Z",
   "modifiedDate": "2015-03-29T00:07:04.866Z"
  },
  {
   "createdDate": "2015-04-18T01:37:04.122Z",
   "modifiedDate": "2015-04-18T01:37:04.122Z"
  },
  {
   "createdDate": "2015-03-27T02:35:44.933Z",
   "modifiedDate": "2015-03-27T02:35:44.933Z"
  },
  {
   "createdDate": "2015-04-01T01:40:05.926Z",
   "modifiedDate": "2015-04-01T01:40:05.926Z"
  },
  {
   "createdDate": "2015-04-04T23:39:23.428Z",
   "modifiedDate": "2015-04-04T23:39:23.428Z"
  },
  {
   "createdDate": "2012-05-09T04:16:44.757Z",
   "modifiedDate": "2010-05-10T09:55:58.920Z",
   "lastViewedByMeDate": "2010-05-10T09:55:58.959Z"
  },
  {
   "createdDate": "2012-02-24T15:09:48.732Z",
   "modifiedDate": "2012-02-24T15:09:48.732Z"
  },
  {
   "createdDate": "2011-08-29T14:11:29.434Z",
   "modifiedDate": "2011-08-29T14:11:44.286Z",
   "lastViewedByMeDate": "2011-08-29T14:11:26.418Z"
  },
  {
   "createdDate": "2015-03-20T02:38:18.181Z",
   "modifiedDate": "2015-03-20T02:38:18.181Z"
  },

我是唯一一个遇到这个大问题的人(在多个帐户上)?

1 个答案:

答案 0 :(得分:1)

为什么

由于您要通过全文查询,因此您将按相关性顺序接收结果列表。不使用全文时。这是一个长期存在的错误,最近才解决。

现在怎么办?

API目前不提供设置排序顺序的功能,因此没有方法可以按最后修改的顺序返回全文搜索。

另类

虽然API当前没有按上次修改日期公开方法排序,但您可以使用边界日期发出多个列表查询。通过查看日期列表,您可以先返回最新结果,然后根据需要加载较旧的匹配项。

例如,在您的全文搜索查询字词之后,您可以首先为自上个月以来修改过的项目添加过滤器:

  • modifiedDate >= '2015-04-06T00:00:00'

如果需要,在收到这组结果后对结果客户端进行排序。

对于后续问题,请按照此模式绑定结果:

  • modifiedDate < '2015-04-06T00:00:00' and modifiedDate >= '2015-03-06T00:00:00'

由于您受到修改日期的限制,因此您可以单独对这些较小的子集进行排序,而不必等待所有内容到达。您应该根据您希望返回的文档数量来缩放时间范围。较大的帐户可能需要每日或每周时间范围。

考虑

免责声明:您将了解您的使用案例,因此这可能不适用于您使用全文搜索的方式。

检查是否/何时确实希望按时间顺序返回这些搜索结果。例如,如果用户搜索May 2010 Budget,则可能首先返回仅包含这3个字中的1个的文档,而2010预算文件可能在列表中为#10,000,用户永远不会看到。