gpt4 book ai didi

java - DocumentList API FullTextQuery ServiceException - 发生未知错误

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

对于某些查询,我在 10 秒后收到此 ServiceException等待回复。

我也尝试过直接 http get 请求并得到相同的结果。

例如:Contract%20Colectiv%20de%20Munc%C4%83

1. My code: 

URL feedUrl = new URL("https://docs.google.com/feeds/default/private/ full/folder%3A" + folderId + "/contents/-/pdf");
DocumentQuery query = new DocumentQuery(feedUrl);
query.setFullTextQuery(searchText);
client.setConnectTimeout(0);// with or without this line I receive the same result (I also put 30000 value - same result)
client.setReadTimeout(0);// with or without this line I receive the same result

DocumentListFeed feed = client.getFeed(query, DocumentListFeed.class);


2. This is the stacktrace for the exception that I receive with documentlist api query:

com.google.gdata.util.ServiceException: An unknown error has occurred.
<errors xmlns='http://schemas.google.com/g/2005'>
<error><domain>GData</domain><code>ServiceException</code>
<internalReason>An unknown error has occurred</internalReason>
</error></errors>
at com.google.gdata.client.http.HttpGDataRequest.handleErrorResponse(HttpGDataRequest.java:624)
at com.google.gdata.client.http.GoogleGDataRequest.handleErrorResponse(GoogleGDataRequest.java:563)
at com.google.gdata.client.http.HttpGDataRequest.checkResponse(HttpGDataRequest.java: 552)
at com.google.gdata.client.http.HttpGDataRequest.execute(HttpGDataRequest.java: 530)
at com.google.gdata.client.http.GoogleGDataRequest.execute(GoogleGDataRequest.java:535)
at com.google.gdata.client.Service.getFeed(Service.java:1135)
...

3. This is the exception I receive with direct http get request:

java.io.IOException: Server returned HTTP response code: 500 for URL: https://docs.google.com/feeds/default/private/full/folder%3[my_folder_doc-id]/contents/-/pdf?q="[query_text]"&max-results=25
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java: 1436)
at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java: 379)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java: 318)
at GoogleDocsManager.googleSearch(GoogleDocsManager.java:281)

其他信息:

1. My folder contains almost 300k files. Could this be the problem? 
2. In ~85% of searches I get the correct response ()
3. In browser the same interogation returns "The server encountered an error. Please try again later", but after refresh works fine.

任何人都可以帮助我找到解决此问题的“解决方法”吗?或者如何躲开它?

几个月前我在 documentlist api group 上发布了这个问题但由于该组是只读的,我无法获得有关此问题的任何信息。

<小时/>

这是我通过直接 http 请求得到的 500 响应(约 10 秒后):

<errors xmlns='http://schemas.google.com/g/2005'>
<error>
<domain>GData</domain>
<code>ServiceException</code>
<internalReason>An unknown error has occurred.</internalReason>
</error>
</errors>

这是代码:

URL feedUrl = new URL("https://docs.google.com/feeds/default/private/full/folder%3A" +  folderId + "/contents/-/pdf?max-results=25&q=" + searchText);                        

HttpURLConnection copyHttpUrlConn = (HttpURLConnection) feedUrl.openConnection();
copyHttpUrlConn.setDoOutput(true);
copyHttpUrlConn.setRequestMethod("GET");
copyHttpUrlConn.setRequestProperty("GData-Version", "3.0");
copyHttpUrlConn.setRequestProperty("Authorization", "GoogleLogin auth=" + authToken);
int respCode = copyHttpUrlConn.getResponseCode();

System.out.println("Response code: " + respCode);

InputStreamReader isr = null;
if(respCode != 200){
isr = new InputStreamReader(copyHttpUrlConn.getErrorStream());
}
else{
isr = new InputStreamReader(copyHttpUrlConn.getInputStream());
}
BufferedReader br = new BufferedReader(isr);

String line = null;
while((line = br.readLine()) != null){
System.out.println(line);
}

其他最近出现问题的查询:

  1. 标题:2012-05“新宪法刑法异常(exception)”
  2. “公共(public)诉讼”
  3. “moş crăciun srl”
  4. “bil terenuri sa bucuresti”
  5. “普拉塔勋章”

最佳答案

作为一种解决方法,您可以考虑使用任务队列离线获取大型文档列表,并序列化要在数据存储中显示的信息。

使用任务队列可以让您在出现错误时自动重试,并为 urlfetch 和处理截止时间提供最多 10 分钟的截止时间。

关于java - DocumentList API FullTextQuery ServiceException - 发生未知错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10335709/

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