Search in sources :

Example 6 with SearchIndexDefinition

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);
}
Also used : Item(io.vertigo.dynamo.search.data.domain.Item) SearchIndexDefinition(io.vertigo.dynamo.search.metamodel.SearchIndexDefinition) DefinitionSpace(io.vertigo.core.definition.DefinitionSpace) Test(org.junit.Test)

Example 7 with SearchIndexDefinition

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();
}
Also used : SearchIndexDefinition(io.vertigo.dynamo.search.metamodel.SearchIndexDefinition)

Example 8 with SearchIndexDefinition

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();
}
Also used : SearchIndexDefinition(io.vertigo.dynamo.search.metamodel.SearchIndexDefinition)

Example 9 with SearchIndexDefinition

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);
}
Also used : Car(io.vertigo.dynamo.search_2_4.data.domain.Car) SearchIndexDefinition(io.vertigo.dynamo.search.metamodel.SearchIndexDefinition) DefinitionSpace(io.vertigo.core.definition.DefinitionSpace) Test(org.junit.Test)

Example 10 with SearchIndexDefinition

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;
    }
}
Also used : Car(io.vertigo.dynamo.search_2_4.data.domain.Car) SearchIndexDefinition(io.vertigo.dynamo.search.metamodel.SearchIndexDefinition) SearchIndex(io.vertigo.dynamo.search.model.SearchIndex) ArrayList(java.util.ArrayList) DtDefinition(io.vertigo.dynamo.domain.metamodel.DtDefinition) VTransactionWritable(io.vertigo.commons.transaction.VTransactionWritable) URI(io.vertigo.dynamo.domain.model.URI)

Aggregations

SearchIndexDefinition (io.vertigo.dynamo.search.metamodel.SearchIndexDefinition)15 ArrayList (java.util.ArrayList)8 URI (io.vertigo.dynamo.domain.model.URI)6 DefinitionSpace (io.vertigo.core.definition.DefinitionSpace)4 DtDefinition (io.vertigo.dynamo.domain.metamodel.DtDefinition)4 SearchIndex (io.vertigo.dynamo.search.model.SearchIndex)4 Test (org.junit.Test)4 VTransactionWritable (io.vertigo.commons.transaction.VTransactionWritable)2 ListFilter (io.vertigo.dynamo.collections.ListFilter)2 KeyConcept (io.vertigo.dynamo.domain.model.KeyConcept)2 Item (io.vertigo.dynamo.search.data.domain.Item)2 Car (io.vertigo.dynamo.search_2_4.data.domain.Car)2 HashMap (java.util.HashMap)2 DtField (io.vertigo.dynamo.domain.metamodel.DtField)1 List (java.util.List)1