NetSuite SuiteTalk 中的 searchMoreWithId 操作结果为空白页 API

Empty page in result of searchMoreWithId operation in NetSuite SuiteTalk API

我遇到了与 NetSuite SuiteTalk API 集成的问题。他们提供 SOAP API 以管理 records/entities 的 ERP。我们通过 search 调用和随后的 searchMoreWithId 调用导入一些记录(库存项目)。

我们提供条件以 search 调用并接收 search_id 响应。搜索结果可能很大,因此我们使用单独的 searchMoreWithId 调用获取每一页结果,同时指定 searchIdpageIndex。 NetSuite SuiteTalk API 文档 - https://docs.oracle.com/cloud/latest/netsuitecs_gs/NSTWP/NSTWP.pdf.

问题是一些 searchMoreWithId return 记录列表的调用。

带有空页面的此类响应示例:

    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <soapenv:Header>
        <platformMsgs:documentInfo xmlns:platformMsgs="urn:messages_2016_2.platform.webservices.netsuite.com">
          <platformMsgs:nsId>WEBSERVICES...</platformMsgs:nsId>
        </platformMsgs:documentInfo>
      </soapenv:Header>
      <soapenv:Body>
        <searchMoreWithIdResponse xmlns="urn:messages_2016_2.platform.webservices.netsuite.com">
          <platformCore:searchResult xmlns:platformCore="urn:core_2016_2.platform.webservices.netsuite.com">
            <platformCore:status isSuccess="true"/>
            <platformCore:totalRecords>98852</platformCore:totalRecords>
            <platformCore:pageSize>10</platformCore:pageSize>
            <platformCore:totalPages>9886</platformCore:totalPages>
            <platformCore:pageIndex>66</platformCore:pageIndex>
            <platformCore:searchId>WEBSERVICES_...</platformCore:searchId>
            <platformCore:recordList/>
          </platformCore:searchResult>
        </searchMoreWithIdResponse>
      </soapenv:Body>
    </soapenv:Envelope>

请注意 platformCore:recordList XML 响应文档中的标签为空。

我注意到一个不变的模式——在空白页面之前没有完整的页面。例如。我们设置页面大小 = 10 并收到以下记录计数作为响应:

page 1496 - 10
page 1497 - 5
page 1498 - 0
page 1499 - 0
page 1500 - 0
page 1501 - 10

我发现只有在官方文档(在上面提供的同一 PDF 文档中)中提到减小页面大小后才发现:

Consider the following possible issues when you execute a search in web services or SuiteScript that returns a large data set.

  • If a record that originally fit the search criteria is updated and no longer fits the criteria, it is skipped by the search. In this case, some records that were originally included in the search results may not be returned, and the total number of returned records may be smaller than the original total number of results.

  • If new records are created that fit the search criteria, they are also returned. The total number of returned records may be higher
    after you page through the results than the original total number of
    results, and duplicate results may be returned.

  • Results may be missing. For example, if a record from the first results page is updated and it no longer fits the criteria, another
    record now fits into page one. However, because earlier pages are
    skipped when going through subsequent pages of search results, this
    record is not returned.

  • In web services, a greater or smaller number of records may be returned after you page through the search results than the number of records that originally fit the search criteria.

  • Page two and the subsequent pages of the results set may contain fewer records than the specified page size.

但不确定是否与我们的情况有关。


所以问题:这是正常情况吗?它不需要一些额外的处理或重试吗?

这是有可能发生的事情。查看at this discussion了解更多信息。

您引用的关键段落in the documentation是:

If a record that originally fit the search criteria is updated and no longer fits the criteria, it is skipped by the search. In this case, some records that were originally included in the search results may not be returned, and the total number of returned records may be smaller than the original total number of results.

这是页面中的实际记录可能与您预期的不同的主要情况。例如,假设您 运行 一个过滤 lastModified 的搜索。如果搜索需要一个小时才能完成 运行,某些记录可能会在您循环搜索结果期间被修改,从而导致在您到达这些记录将要访问的页面时,它们已从搜索结果中删除已包含在搜索结果中。