com.google.appengine.api.search.SearchException Java Examples
The following examples show how to use
com.google.appengine.api.search.SearchException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: VmApiProxyDelegate.java From appengine-java-vm-runtime with Apache License 2.0 | 5 votes |
RuntimeException constructApiException(String packageName, String methodName) { String message = "RCP Failure for API call: " + packageName + " " + methodName; switch (packageName) { case "taskqueue": return new TransientFailureException(message); case "app_identity_service": return new AppIdentityServiceFailureException(message); case "blobstore": return new BlobstoreFailureException(message); case "channel": return new ChannelFailureException(message); case "images": return new ImagesServiceFailureException(message); case "logservice": return constructException( LogServiceException.class.getName(), message, packageName, methodName); case "memcache": return new MemcacheServiceException(message); case "modules": return constructException( ModulesException.class.getName(), message, packageName, methodName); case "search": return new SearchException(message); case "user": return new UserServiceFailureException(message); case "xmpp": return new XMPPFailureException(message); default: // Cover all datastore versions: if (packageName.startsWith("datastore")) { return new DatastoreFailureException(message); } else { return new RPCFailedException(packageName, methodName); } } }
Example #2
Source File: SearchOptionServlet.java From java-docs-samples with Apache License 2.0 | 4 votes |
private Results<ScoredDocument> doSearch() { String indexName = SEARCH_INDEX; // [START search_with_options] try { // Build the SortOptions with 2 sort keys SortOptions sortOptions = SortOptions.newBuilder() .addSortExpression( SortExpression.newBuilder() .setExpression("price") .setDirection(SortExpression.SortDirection.DESCENDING) .setDefaultValueNumeric(0)) .addSortExpression( SortExpression.newBuilder() .setExpression("brand") .setDirection(SortExpression.SortDirection.DESCENDING) .setDefaultValue("")) .setLimit(1000) .build(); // Build the QueryOptions QueryOptions options = QueryOptions.newBuilder() .setLimit(25) .setFieldsToReturn("model", "price", "description") .setSortOptions(sortOptions) .build(); // A query string String queryString = "product: coffee roaster AND price < 500"; // Build the Query and run the search Query query = Query.newBuilder().setOptions(options).build(queryString); IndexSpec indexSpec = IndexSpec.newBuilder().setName(indexName).build(); Index index = SearchServiceFactory.getSearchService().getIndex(indexSpec); Results<ScoredDocument> result = index.search(query); return result; } catch (SearchException e) { // handle exception... } // [END search_with_options] return null; }