我的Java Google App Engine的本地实例似乎很好地索引搜索文档,但在运行搜索时开始抛出异常。包含代码段和例外。 TIA!
搜索代码:
QueryOptions options = QueryOptions.newBuilder()
.setLimit(500)
.build();
String queryString = searchStr;
Query query = Query.newBuilder().setOptions(options).build(queryString);
IndexSpec indexSpec = IndexSpec.newBuilder().setName(projectName + "Search").build();
Index index = SearchServiceFactory.getSearchService().getIndex(indexSpec);
Results<ScoredDocument> results = null;
try {
results = index.search(query);
} catch (SearchException e) {
}
例外:
java.lang.NullPointerException at com.google.appengine.repackaged.com.google.appengine.api.search.SearchServicePb $ ListDocumentsResponse $ Builder.addDocument(SearchServicePb.java:13298) 在 com.google.appengine.api.search.dev.LocalSearchService.listDocumentsForApp(LocalSearchService.java:527) 在 com.google.appengine.api.search.dev.LocalSearchService.getFieldTypes(LocalSearchService.java:710) 在 com.google.appengine.api.search.dev.LocalSearchService.searchForApp(LocalSearchService.java:564) 在 com.google.appengine.api.search.dev.LocalSearchService.search(LocalSearchService.java:547) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 在 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 在java.lang.reflect.Method.invoke(Method.java:606)at com.google.appengine.tools.development.ApiProxyLocalImpl $ AsyncApiCall.callInternal(ApiProxyLocalImpl.java:525) 在 com.google.appengine.tools.development.ApiProxyLocalImpl $ AsyncApiCall.call(ApiProxyLocalImpl.java:479) 在 com.google.appengine.tools.development.ApiProxyLocalImpl $ AsyncApiCall.call(ApiProxyLocalImpl.java:456) 在 java.util.concurrent.Executors $ PrivilegedCallable $ 1.run(Executors.java:493) 在java.security.AccessController.doPrivileged(Native Method)at java.util.concurrent.Executors $ PrivilegedCallable.call(Executors.java:490) 在java.util.concurrent.FutureTask.run(FutureTask.java:262)at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) 在 java.util.concurrent.ThreadPoolExecutor中的$ Worker.run(ThreadPoolExecutor.java:615) 在java.lang.Thread.run(Thread.java:744)