}
/**
- * Index all views if the index is empty.
- * Only used on startup.
+ * Index all views if the index is empty (Only used on startup).
+ * It's currently not possible to index only data from db that are not existing in the index because we have no way to last when the structure of a view is changed :
+ * - Either the definition has changed -> No updated at column in the projects table,
+ * - Either the view is defined by a regex -> A new analysed project automatically steps into the view.
*
* The views lookup cache will not be cleared
*/
import java.io.FileInputStream;
import java.util.Collections;
import java.util.List;
+import java.util.Map;
import static com.google.common.collect.Lists.newArrayList;
import static org.assertj.core.api.Assertions.assertThat;
bulk.get();
}
+ public void putDocuments(String index, String type, Map<String, Object>... docs) throws Exception {
+ BulkRequestBuilder bulk = client.prepareBulk().setRefresh(true);
+ for (Map<String, Object> doc : docs) {
+ bulk.add(new IndexRequest(index, type).source(doc));
+ }
+ bulk.get();
+ }
+
public long countDocuments(String indexName, String typeName) {
return client().prepareCount(indexName).setTypes(typeName).get().getCount();
}