use of org.apache.lucene.search.WildcardQuery in project drools-wb by kiegroup.
the class IndexRuleAttributeNameAndValueTest method testIndexDrlRuleAttributeNameAndValues.
@Test
public void testIndexDrlRuleAttributeNameAndValues() throws IOException, InterruptedException {
// Add test files
final Path path = basePath.resolve("drl1.rdrl");
final String drl = loadText("drl1.rdrl");
ioService().write(path, drl);
// wait for events to be consumed from jgit -> (notify changes -> watcher -> index) -> lucene index
Thread.sleep(5000);
List<String> index = Arrays.asList(KObjectUtil.toKCluster(basePath.getFileSystem()).getClusterId());
{
final BooleanQuery.Builder queryBuilder = new BooleanQuery.Builder();
ValueSharedPartIndexTerm indexTerm = new ValueSharedPartIndexTerm("*", PartType.RULEFLOW_GROUP);
queryBuilder.add(new WildcardQuery(new Term(indexTerm.getTerm(), indexTerm.getValue())), BooleanClause.Occur.MUST);
queryBuilder.add(new WildcardQuery(new Term("shared:nonexistend", "*")), BooleanClause.Occur.MUST);
searchFor(index, queryBuilder.build(), 0);
}
{
// This could also just be a TermQuery..
final BooleanQuery.Builder queryBuilder = new BooleanQuery.Builder();
ValueSharedPartIndexTerm indexTerm = new ValueSharedPartIndexTerm("myruleflowgroup", PartType.RULEFLOW_GROUP);
queryBuilder.add(new TermQuery(new Term(indexTerm.getTerm(), indexTerm.getValue())), BooleanClause.Occur.MUST);
searchFor(index, queryBuilder.build(), 1);
}
}
Aggregations