Search in sources :

Example 1 with AccumuloFreeTextIndexer

use of org.apache.rya.indexing.accumulo.freetext.AccumuloFreeTextIndexer in project incubator-rya by apache.

the class RyaOutputFormatTest method testFreeTextIndexing.

@Test
public void testFreeTextIndexing() throws Exception {
    final AccumuloFreeTextIndexer ft = new AccumuloFreeTextIndexer();
    ft.setConf(conf);
    final RyaStatement input = RyaStatement.builder().setSubject(new RyaURI(GRAPH + ":s")).setPredicate(new RyaURI(GRAPH + ":p")).setObject(new RyaType(XMLSchema.STRING, "one two three four five")).build();
    RyaOutputFormat.setCoreTablesEnabled(job, false);
    RyaOutputFormat.setFreeTextEnabled(job, true);
    RyaOutputFormat.setTemporalEnabled(job, false);
    RyaOutputFormat.setEntityEnabled(job, false);
    write(input);
    final Set<Statement> empty = new HashSet<>();
    final Set<Statement> expected = new HashSet<>();
    expected.add(RyaToRdfConversions.convertStatement(input));
    Assert.assertEquals(expected, getSet(ft.queryText("one", new StatementConstraints())));
    Assert.assertEquals(empty, getSet(ft.queryText("!two", new StatementConstraints())));
    Assert.assertEquals(expected, getSet(ft.queryText("*r", new StatementConstraints())));
    Assert.assertEquals(empty, getSet(ft.queryText("r*", new StatementConstraints())));
    Assert.assertEquals(expected, getSet(ft.queryText("!r*", new StatementConstraints())));
    Assert.assertEquals(expected, getSet(ft.queryText("t* & !s*", new StatementConstraints())));
    ft.close();
}
Also used : RyaURI(org.apache.rya.api.domain.RyaURI) StatementConstraints(org.apache.rya.indexing.StatementConstraints) AccumuloFreeTextIndexer(org.apache.rya.indexing.accumulo.freetext.AccumuloFreeTextIndexer) Statement(org.openrdf.model.Statement) RyaStatement(org.apache.rya.api.domain.RyaStatement) RyaStatement(org.apache.rya.api.domain.RyaStatement) RyaType(org.apache.rya.api.domain.RyaType) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 2 with AccumuloFreeTextIndexer

use of org.apache.rya.indexing.accumulo.freetext.AccumuloFreeTextIndexer in project incubator-rya by apache.

the class RyaOutputFormat method getFreeTextIndexer.

private static FreeTextIndexer getFreeTextIndexer(final Configuration conf) throws IOException {
    if (!conf.getBoolean(ENABLE_FREETEXT, true)) {
        return null;
    }
    final AccumuloFreeTextIndexer freeText = new AccumuloFreeTextIndexer();
    freeText.setConf(conf);
    Connector connector;
    try {
        connector = ConfigUtils.getConnector(conf);
    } catch (AccumuloException | AccumuloSecurityException e) {
        throw new IOException("Error when attempting to create a connection for writing the freeText index.", e);
    }
    final MultiTableBatchWriter mtbw = connector.createMultiTableBatchWriter(new BatchWriterConfig());
    freeText.setConnector(connector);
    freeText.setMultiTableBatchWriter(mtbw);
    freeText.init();
    return freeText;
}
Also used : Connector(org.apache.accumulo.core.client.Connector) AccumuloException(org.apache.accumulo.core.client.AccumuloException) AccumuloFreeTextIndexer(org.apache.rya.indexing.accumulo.freetext.AccumuloFreeTextIndexer) MultiTableBatchWriter(org.apache.accumulo.core.client.MultiTableBatchWriter) BatchWriterConfig(org.apache.accumulo.core.client.BatchWriterConfig) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) IOException(java.io.IOException)

Example 3 with AccumuloFreeTextIndexer

use of org.apache.rya.indexing.accumulo.freetext.AccumuloFreeTextIndexer in project incubator-rya by apache.

the class FilterFunctionOptimizer method init.

private synchronized void init() {
    if (!init) {
        if (ConfigUtils.getUseMongo(conf)) {
            StatefulMongoDBRdfConfiguration stateConf = (StatefulMongoDBRdfConfiguration) conf;
            for (final MongoSecondaryIndex indexer : stateConf.getAdditionalIndexers()) {
                if (indexer instanceof FreeTextIndexer) {
                    freeTextIndexer = (FreeTextIndexer) indexer;
                } else if (indexer instanceof TemporalIndexer) {
                    temporalIndexer = (TemporalIndexer) indexer;
                }
            }
        } else {
            freeTextIndexer = new AccumuloFreeTextIndexer();
            freeTextIndexer.setConf(conf);
            temporalIndexer = new AccumuloTemporalIndexer();
            temporalIndexer.setConf(conf);
        }
        init = true;
    }
}
Also used : StatefulMongoDBRdfConfiguration(org.apache.rya.mongodb.StatefulMongoDBRdfConfiguration) AccumuloFreeTextIndexer(org.apache.rya.indexing.accumulo.freetext.AccumuloFreeTextIndexer) AccumuloTemporalIndexer(org.apache.rya.indexing.accumulo.temporal.AccumuloTemporalIndexer) AccumuloTemporalIndexer(org.apache.rya.indexing.accumulo.temporal.AccumuloTemporalIndexer) MongoSecondaryIndex(org.apache.rya.mongodb.MongoSecondaryIndex) AccumuloFreeTextIndexer(org.apache.rya.indexing.accumulo.freetext.AccumuloFreeTextIndexer)

Example 4 with AccumuloFreeTextIndexer

use of org.apache.rya.indexing.accumulo.freetext.AccumuloFreeTextIndexer in project incubator-rya by apache.

the class GeoEnabledFilterFunctionOptimizer method init.

/**
 * Load instances of the selected indexers.  This is tricky because some (geomesa vs geowave) have incompatible dependencies (geotools versions).
 */
private synchronized void init() {
    if (!init) {
        if (ConfigUtils.getUseMongo(conf)) {
            // create a new MongoGeoIndexer() without having it at compile time.
            StatefulMongoDBRdfConfiguration stateConf = (StatefulMongoDBRdfConfiguration) conf;
            for (final MongoSecondaryIndex indexer : stateConf.getAdditionalIndexers()) {
                if (indexer instanceof FreeTextIndexer) {
                    freeTextIndexer = (FreeTextIndexer) indexer;
                } else if (indexer instanceof TemporalIndexer) {
                    temporalIndexer = (TemporalIndexer) indexer;
                } else if (indexer instanceof GeoIndexer) {
                    geoIndexer = (GeoIndexer) indexer;
                }
            }
        } else {
            GeoIndexerType geoIndexerType = OptionalConfigUtils.getGeoIndexerType(conf);
            if (geoIndexerType == GeoIndexerType.UNSPECIFIED) {
                geoIndexer = instantiate(GeoIndexerType.GEO_MESA.getGeoIndexerClassString(), GeoIndexer.class);
            } else {
                geoIndexer = instantiate(geoIndexerType.getGeoIndexerClassString(), GeoIndexer.class);
            }
            geoIndexer.setConf(conf);
            freeTextIndexer = new AccumuloFreeTextIndexer();
            freeTextIndexer.setConf(conf);
            temporalIndexer = new AccumuloTemporalIndexer();
            temporalIndexer.setConf(conf);
        }
        init = true;
    }
}
Also used : StatefulMongoDBRdfConfiguration(org.apache.rya.mongodb.StatefulMongoDBRdfConfiguration) AccumuloFreeTextIndexer(org.apache.rya.indexing.accumulo.freetext.AccumuloFreeTextIndexer) AccumuloTemporalIndexer(org.apache.rya.indexing.accumulo.temporal.AccumuloTemporalIndexer) AccumuloTemporalIndexer(org.apache.rya.indexing.accumulo.temporal.AccumuloTemporalIndexer) MongoSecondaryIndex(org.apache.rya.mongodb.MongoSecondaryIndex) AccumuloFreeTextIndexer(org.apache.rya.indexing.accumulo.freetext.AccumuloFreeTextIndexer)

Aggregations

AccumuloFreeTextIndexer (org.apache.rya.indexing.accumulo.freetext.AccumuloFreeTextIndexer)4 AccumuloTemporalIndexer (org.apache.rya.indexing.accumulo.temporal.AccumuloTemporalIndexer)2 MongoSecondaryIndex (org.apache.rya.mongodb.MongoSecondaryIndex)2 StatefulMongoDBRdfConfiguration (org.apache.rya.mongodb.StatefulMongoDBRdfConfiguration)2 IOException (java.io.IOException)1 HashSet (java.util.HashSet)1 AccumuloException (org.apache.accumulo.core.client.AccumuloException)1 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)1 BatchWriterConfig (org.apache.accumulo.core.client.BatchWriterConfig)1 Connector (org.apache.accumulo.core.client.Connector)1 MultiTableBatchWriter (org.apache.accumulo.core.client.MultiTableBatchWriter)1 RyaStatement (org.apache.rya.api.domain.RyaStatement)1 RyaType (org.apache.rya.api.domain.RyaType)1 RyaURI (org.apache.rya.api.domain.RyaURI)1 StatementConstraints (org.apache.rya.indexing.StatementConstraints)1 Test (org.junit.Test)1 Statement (org.openrdf.model.Statement)1