gpt4 book ai didi

java - 在电子表格中搜索不适用于创建的新文件

转载 作者:行者123 更新时间:2023-12-01 05:21:34 24 4
gpt4 key购买 nike

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

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 小时)更新文件,查询将在结果中返回它们。

最佳答案

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

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

“目前,可能需要大约 10 分钟才能将您写入电子表格的内容编入索引。因此,如果您输入某些内容,然后立即搜索它,它可能还不会显示在您的列表中记录结果。再等几分钟(我们正在努力加快速度)”

关于java - 在电子表格中搜索不适用于创建的新文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10334919/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com