use of io.vertigo.dynamo.search.metamodel.SearchIndexDefinition in project vertigo by KleeGroup.
the class SearchManagerMultiIndexTest method testIndex.
/**
* Test de création de n enregistrements dans l'index.
* La création s'effectue dans une seule transaction mais sur deux indexes.
* Vérifie la capacité du système à gérer plusieurs indexes.
*/
@Test
public void testIndex() {
final DefinitionSpace definitionSpace = getApp().getDefinitionSpace();
final SearchIndexDefinition itemIndexDefinition = definitionSpace.resolve(IDX_ITEM, SearchIndexDefinition.class);
final SearchIndexDefinition itemDynIndexDefinition = definitionSpace.resolve(IDX_DYNA_ITEM, SearchIndexDefinition.class);
for (final Item item : itemDataBase.getAllItems()) {
final SearchIndex<Item, Item> index = SearchIndex.createIndex(itemIndexDefinition, item.getURI(), item);
searchManager.put(itemIndexDefinition, index);
final SearchIndex<Item, Item> index2 = SearchIndex.createIndex(itemDynIndexDefinition, item.getURI(), item);
searchManager.put(itemDynIndexDefinition, index2);
}
waitIndexation();
final long size = query("*:*", itemIndexDefinition);
Assert.assertEquals(itemDataBase.size(), size);
final long sizeDyn = query("*:*", itemDynIndexDefinition);
Assert.assertEquals(itemDataBase.size(), sizeDyn);
}
use of io.vertigo.dynamo.search.metamodel.SearchIndexDefinition in project vertigo by KleeGroup.
the class AbstractESSearchServicesPlugin method start.
/**
* {@inheritDoc}
*/
@Override
public final void start() {
// Init ElasticSearch Client
esClient = createClient();
indexSettingsValid = true;
// must wait yellow status to be sure prepareExists works fine (instead of returning false on a already exist index)
waitForYellowStatus();
// Init typeMapping IndexDefinition <-> Conf ElasticSearch
for (final SearchIndexDefinition indexDefinition : Home.getApp().getDefinitionSpace().getAll(SearchIndexDefinition.class)) {
final String myIndexName = obtainIndexName(indexDefinition);
createIndex(myIndexName);
updateTypeMapping(indexDefinition, hasSortableNormalizer(myIndexName));
logMappings(myIndexName);
types.add(indexDefinition.getName().toLowerCase(Locale.ROOT));
}
waitForYellowStatus();
}
use of io.vertigo.dynamo.search.metamodel.SearchIndexDefinition in project vertigo by KleeGroup.
the class AbstractESSearchServicesPlugin method start.
/**
* {@inheritDoc}
*/
@Override
public final void start() {
// Init ElasticSearch Client
esClient = createClient();
indexSettingsValid = true;
// must wait yellow status to be sure prepareExists works fine (instead of returning false on a already exist index)
waitForYellowStatus();
// Init typeMapping IndexDefinition <-> Conf ElasticSearch
for (final SearchIndexDefinition indexDefinition : Home.getApp().getDefinitionSpace().getAll(SearchIndexDefinition.class)) {
final String myIndexName = obtainIndexName(indexDefinition);
createIndex(myIndexName);
updateTypeMapping(indexDefinition);
logMappings(myIndexName);
types.add(indexDefinition.getName().toLowerCase(Locale.ENGLISH));
}
waitForYellowStatus();
}
use of io.vertigo.dynamo.search.metamodel.SearchIndexDefinition in project vertigo by KleeGroup.
the class SearchManagerMultiIndexTest method testIndex.
/**
* Test de création de n enregistrements dans l'index.
* La création s'effectue dans une seule transaction mais sur deux indexes.
* Vérifie la capacité du système à gérer plusieurs indexes.
*/
@Test
public void testIndex() {
final DefinitionSpace definitionSpace = getApp().getDefinitionSpace();
final SearchIndexDefinition carIndexDefinition = definitionSpace.resolve(IDX_CAR, SearchIndexDefinition.class);
final SearchIndexDefinition carDynIndexDefinition = definitionSpace.resolve(IDX_DYNA_CAR, SearchIndexDefinition.class);
for (final Car car : carDataBase.getAllCars()) {
final SearchIndex<Car, Car> index = SearchIndex.createIndex(carIndexDefinition, car.getURI(), car);
searchManager.put(carIndexDefinition, index);
final SearchIndex<Car, Car> index2 = SearchIndex.createIndex(carDynIndexDefinition, car.getURI(), car);
searchManager.put(carDynIndexDefinition, index2);
}
waitIndexation();
final long sizeCar = query("*:*", carIndexDefinition);
Assert.assertEquals(carDataBase.size(), sizeCar);
final long sizeCarDyn = query("*:*", carDynIndexDefinition);
Assert.assertEquals(carDataBase.size(), sizeCarDyn);
}
use of io.vertigo.dynamo.search.metamodel.SearchIndexDefinition in project vertigo by KleeGroup.
the class CarSearchLoader method loadData.
/**
* {@inheritDoc}
*/
@Override
public List<SearchIndex<Car, Car>> loadData(final SearchChunk<Car> searchChunk) {
final SearchIndexDefinition indexDefinition = searchManager.findFirstIndexDefinitionByKeyConcept(Car.class);
try (final VTransactionWritable tx = getTransactionManager().createCurrentTransaction()) {
final List<SearchIndex<Car, Car>> result = new ArrayList<>();
final DtDefinition dtDefinition = DtObjectUtil.findDtDefinition(Car.class);
for (final Car car : loadCarList(searchChunk)) {
final URI<Car> uri = new URI<>(dtDefinition, car.getId());
result.add(SearchIndex.createIndex(indexDefinition, uri, car));
}
return result;
}
}
Aggregations