Exemplo n.º 1
0
  protected int removeAll() {
    int count = 0;
    Index index = getIndex();
    GetRequest request = GetRequest.newBuilder().setReturningIdsOnly(true).setLimit(200).build();
    GetResponse<Document> response = index.getRange(request);

    // can only delete documents in blocks of 200 so we need to iterate until they're all gone
    while (!response.getResults().isEmpty()) {
      List<String> ids = new ArrayList<String>();
      for (Document document : response) {
        ids.add(document.getId());
      }
      index.delete(ids);
      count += ids.size();
      response = index.getRange(request);
    }
    return count;
  }
Exemplo n.º 2
0
 @PostConstruct
 private void loadRows() {
   rows = new ArrayList<Row>();
   try {
     NamespaceManager.validateNamespace(namespace);
   } catch (Exception e) {
     errorMessage = e.getMessage();
     return;
   }
   NamespaceManager.set(namespace);
   try {
     SearchService search = SearchServiceFactory.getSearchService(namespace);
     GetResponse<Index> response =
         search.getIndexes(
             GetIndexesRequest.newBuilder().setIndexNamePrefix(indexNamePrefix).build());
     for (Index index : response.getResults()) {
       rows.add(new Row(index));
     }
   } finally {
     NamespaceManager.set("");
   }
 }