1

我使用文档列表 api 在 google docs 上创建了我的电子表格模板的副本,我意识到:

1. title queries works fine
2. content queries are not working(*) or partially working(**)
(*)for majority of spreadsheets: I searched every word from the content of a spreadsheet and I get no results
(**) for a few spreadsheets I find results for some words that are copied from template; the particular words queries are not working
3. If I update the spreadsheet after a few minutes all queries work fine.
(I make this searches from UI)

这是创建此文件的步骤:

1. Copy spreadsheet template to root

private String sendPostCopyRequest(String authorizationToken, String resourceID, String title, int noRetries) throws IOException{ 
    /*
    resourceId = resource id for the template that i want to copy
    title = the title of the new file created
    */      
    String urlStr = "https://docs.google.com/feeds/default/private/full";
    URL url = new URL(urlStr); 
    HttpURLConnection copyHttpUrlConn = (HttpURLConnection) url.openConnection(); 
    copyHttpUrlConn.setDoOutput(true); 
    copyHttpUrlConn.setRequestMethod("POST"); 

    String outputString = "<?xml version='1.0' encoding='UTF-8'?>" +
            "<entry xmlns=\"http://www.w3.org/2005/Atom\"> " +
            "<id>https://docs.google.com/feeds/default/private/full/" + resourceID +"</id>" +
            " <title>" + title + "</title></entry>";

    copyHttpUrlConn.setRequestProperty("GData-Version", "3.0");
    copyHttpUrlConn.setRequestProperty("Content-Type","application/atom+xml");

    copyHttpUrlConn.setRequestProperty("Content-Length", outputString.length() + "");
    copyHttpUrlConn.setRequestProperty("Authorization", "GoogleLogin auth=" + authorizationToken);

    OutputStream outputStream = copyHttpUrlConn.getOutputStream(); 

    outputStream.write(outputString.getBytes()); 
    copyHttpUrlConn.getResponseCode(); 

    return readIdFromResponse(copyHttpUrlConn.getInputStream()); 
}

2. I update some cells using this method:

public boolean setCellValue(SpreadsheetService spreadSheetService, SpreadsheetEntry entry, int worksheetNumber, String position, String value) throws IOException, ServiceException {

    List<WorksheetEntry> worksheets = entry.getWorksheets();
    WorksheetEntry worksheet = worksheets.get(worksheetNumber);
    URL cellFeedUrl = worksheet.getCellFeedUrl();
    CellQuery query = new CellQuery(cellFeedUrl);
    query.setReturnEmpty(true);
    query.setRange(position);
    CellFeed cellFeed = spreadSheetService.query(query, CellFeed.class);
    CellEntry cell = cellFeed.getEntries().get(0);

    cell.changeInputValueLocal(value);
    cell.update();
    return true;

}

3. I move the created file to a new folder (collection)

    public DocumentListEntry moveSpreadSheet(DocsService docsService, String entryId, String destinationFolderDocId) throws MalformedURLException, IOException, ServiceException {

    DocumentListEntry newEntry = null;
    newEntry = new com.google.gdata.data.docs.SpreadsheetEntry();
    newEntry.setId(entryId);
    String destFolderUri = "https://docs.google.com/feeds/default/private/full/folder%3A"+ destinationFolderDocId + "/contents";

    return docsService.insert(new URL(destFolderUri), newEntry);

}

(the same results with gdata java sdk api 1.4.5, 1.4.6, 1.4.7)

这发生在 2011 年 12 月 23 日(近似值)。对于在此日期之前使用相同代码创建的所有电子表格,所有查询都可以正常工作。

我可以根据要求提供任何其他信息。

更新:

  1. 这个问题似乎也出现在上传带有转换的电子表格时。
  2. 如果我在创建/上传后一段时间(约 2 小时)后更新文件,查询会在结果中返回它们。
4

1 回答 1

0

您的问题可能与 Google 对电子表格内容的索引速度较慢有关。

https://groups.google.com/a/googleproductforums.com/d/msg/docs/vEhI_HkKX3I/MGKqkryrx90J

“目前,将您写入电子表格的内容编入索引可能需要大约 10 分钟。因此,如果您输入一些内容,然后立即搜索,它可能尚未显示在您的文档结果列表中。再等几分钟(我们正在努力让它更快)”

于 2012-05-07T08:07:10.013 回答