Search in sources :

Example 1 with NeedIndexer

use of won.matcher.solr.index.NeedIndexer in project webofneeds by researchstudio-sat.

the class SolrNeedIndexer method main.

public static void main(String[] args) throws IOException, InterruptedException, JsonLdError {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(SolrTestAppConfiguration.class);
    NeedIndexer indexer = ctx.getBean(NeedIndexer.class);
    // set the options of the need producer (e.g. if it should exhaust) in the SolrNeedIndexerAppConfiguration file
    NeedProducer needProducer = ctx.getBean(RoundRobinCompositeNeedProducer.class);
    Model needModel = new NeedModelWrapper(needProducer.create()).copyNeedModel(NeedGraphType.NEED);
    int needs = 0;
    while (!needProducer.isExhausted()) {
        // indexer.indexNeedModel(needModel, UUID.randomUUID().toString(), true);
        Dataset ds = DatasetFactory.createTxnMem();
        ds.addNamedModel("https://node.matchat.org/won/resource/need/test#need", needModel);
        NeedModelWrapper needModelWrapper = new NeedModelWrapper(needModel, null);
        needModel = needModelWrapper.normalizeNeedModel();
        indexer.indexNeedModel(needModel, SolrMatcherEvaluation.createNeedId(ds), true);
        needs++;
        if (needs % 100 == 0) {
            System.out.println("Indexed " + needs + " needs.");
        }
        needModel = new NeedModelWrapper(needProducer.create()).copyNeedModel(NeedGraphType.NEED);
    }
    System.out.println("Indexed " + needs + " needs.");
    System.exit(0);
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) NeedIndexer(won.matcher.solr.index.NeedIndexer) Dataset(org.apache.jena.query.Dataset) Model(org.apache.jena.rdf.model.Model) NeedModelWrapper(won.protocol.util.NeedModelWrapper) RoundRobinCompositeNeedProducer(won.bot.framework.component.needproducer.impl.RoundRobinCompositeNeedProducer) NeedProducer(won.bot.framework.component.needproducer.NeedProducer)

Aggregations

Dataset (org.apache.jena.query.Dataset)1 Model (org.apache.jena.rdf.model.Model)1 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)1 NeedProducer (won.bot.framework.component.needproducer.NeedProducer)1 RoundRobinCompositeNeedProducer (won.bot.framework.component.needproducer.impl.RoundRobinCompositeNeedProducer)1 NeedIndexer (won.matcher.solr.index.NeedIndexer)1 NeedModelWrapper (won.protocol.util.NeedModelWrapper)1