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();
}
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;
}
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;
}
}
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;
}
}
Aggregations