Search in sources :

Example 6 with SearchIndex

use of io.vertigo.dynamo.search.model.SearchIndex in project vertigo by KleeGroup.

the class ItemSearchLoader method loadData.

/**
 * {@inheritDoc}
 */
@Override
public List<SearchIndex<Item, Item>> loadData(final SearchChunk<Item> searchChunk) {
    final SearchIndexDefinition indexDefinition = searchManager.findFirstIndexDefinitionByKeyConcept(Item.class);
    try (final VTransactionWritable tx = getTransactionManager().createCurrentTransaction()) {
        final List<SearchIndex<Item, Item>> result = new ArrayList<>();
        final DtDefinition dtDefinition = DtObjectUtil.findDtDefinition(Item.class);
        for (final Item item : loadItems(searchChunk)) {
            final URI<Item> uri = new URI<>(dtDefinition, item.getId());
            result.add(SearchIndex.createIndex(indexDefinition, uri, item));
        }
        return result;
    }
}
Also used : Item(io.vertigo.dynamo.search.data.domain.Item) 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)

Example 7 with SearchIndex

use of io.vertigo.dynamo.search.model.SearchIndex in project vertigo by KleeGroup.

the class ReindexTask method loadAndIndex.

private void loadAndIndex(final SearchChunk<? extends KeyConcept> searchChunk) {
    final SearchLoader searchLoader = Home.getApp().getComponentSpace().resolve(searchIndexDefinition.getSearchLoaderId(), SearchLoader.class);
    final Collection<SearchIndex<KeyConcept, DtObject>> searchIndexes;
    searchIndexes = searchLoader.loadData(searchChunk);
    removedNotFoundKeyConcept(searchIndexes, searchChunk);
    if (!searchIndexes.isEmpty()) {
        searchManager.putAll(searchIndexDefinition, searchIndexes);
    }
}
Also used : SearchIndex(io.vertigo.dynamo.search.model.SearchIndex) SearchLoader(io.vertigo.dynamo.search.metamodel.SearchLoader)

Aggregations

SearchIndex (io.vertigo.dynamo.search.model.SearchIndex)7 ArrayList (java.util.ArrayList)5 SearchIndexDefinition (io.vertigo.dynamo.search.metamodel.SearchIndexDefinition)4 VTransactionWritable (io.vertigo.commons.transaction.VTransactionWritable)2 DtDefinition (io.vertigo.dynamo.domain.metamodel.DtDefinition)2 URI (io.vertigo.dynamo.domain.model.URI)2 Car (io.vertigo.dynamo.search_2_4.data.domain.Car)2 HashMap (java.util.HashMap)2 DtObject (io.vertigo.dynamo.domain.model.DtObject)1 KeyConcept (io.vertigo.dynamo.domain.model.KeyConcept)1 Item (io.vertigo.dynamo.search.data.domain.Item)1 SearchLoader (io.vertigo.dynamo.search.metamodel.SearchLoader)1 VSystemException (io.vertigo.lang.VSystemException)1