我在谷歌文檔與文件列表API創建我的電子表格模板的副本,我意識到:搜索創建
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日(與aproximation)。對於在此日期之前使用相同代碼創建的所有電子表格,所有查詢均可正常工作。
我可以根據要求提供其他信息。
更新:
- 這個問題似乎與轉換上傳電子表格中也出現。
- 如果我在創建/上傳(〜2小時)後的一段時間後更新文件,查詢將返回結果中的文件。
我和其他幾個人報告GoogleDocs在電子表格中的搜索功能已損壞(Google支持論壇,現在無法找到該鏈接)。一位谷歌員工證實,舊文件沒有編入索引(AFAIK由於某個時間點的錯誤),我們必須打開並編輯它們才能重新編制索引。但是,今天我發現電子表格中的搜索不適用於8天前創建的傳播熱,因此我認爲該錯誤再次出現。我建議你搜索谷歌論壇,看看你是否可以找到目前的狀態。 – user77115 2012-05-07 07:37:21
我知道那篇文章,因爲我也在那裏報道(這是鏈接 - [鏈接](http://productforfors.google.com/forum/#!starred/docs/vEhI_HkKX3I)),但它是關於創建的文件從UI。我會在那裏通知他們(似乎對於從UI新上傳的文件是同樣的問題,但在一個單元更新工作正常) – 2012-05-07 11:47:24