com.google.appengine.api.search.Index

Here are the examples of the java api class com.google.appengine.api.search.Index taken from open source projects.

1. MaintenanceTasksServlet#removeAllDocumentsFromIndex()

Project: solutions-mobile-shopping-assistant-backend-java
File: MaintenanceTasksServlet.java
private void removeAllDocumentsFromIndex() {
    Index index = PlacesHelper.getIndex();
    GetRequest request = GetRequest.newBuilder().setReturningIdsOnly(true).build();
    GetResponse<Document> response = index.getRange(request);
    for (Document document : response.getResults()) {
        index.delete(document.getId());
    }
}

2. MaintenanceTasksServlet#buildSearchIndexForPlaces()

Project: solutions-mobile-shopping-assistant-backend-java
File: MaintenanceTasksServlet.java
@SuppressWarnings({ "cast", "unchecked" })
private boolean buildSearchIndexForPlaces() {
    Index index = PlacesHelper.getIndex();
    removeAllDocumentsFromIndex();
    EntityManager mgr = getEntityManager();
    try {
        Query query = mgr.createQuery("select from Place as Place");
        for (Object obj : (List<Object>) query.getResultList()) {
            Place place = (Place) obj;
            Document placeAsDocument = PlacesHelper.buildDocument(place.getPlaceId(), place.getName(), place.getAddress(), place.getLocation());
            try {
                index.put(placeAsDocument);
            } catch (PutException e) {
                if (StatusCode.TRANSIENT_ERROR.equals(e.getOperationResult().getCode())) {
                    return false;
                }
            }
        }
    } catch (Exception e) {
        return false;
    } finally {
        mgr.close();
    }
    return true;
}