final Index index = getConfig().getIndexManager().get( org.uberfire.metadata.io.KObjectUtil.toKCluster( basePath.getFileSystem() ) );
{
final IndexSearcher searcher = ( (LuceneIndex) index ).nrtSearcher();
final TopScoreDocCollector collector = TopScoreDocCollector.create( 10,
true );
final BooleanQuery query = new BooleanQuery();
query.add( new TermQuery( new Term( RuleAttributeIndexTerm.TERM,
"ruleflow-group" ) ),
BooleanClause.Occur.MUST );
query.add( new TermQuery( new Term( RuleAttributeValueIndexTerm.TERM,
"nonexistent" ) ),
BooleanClause.Occur.MUST );
searcher.search( query,
collector );
final ScoreDoc[] hits = collector.topDocs().scoreDocs;
assertEquals( 0,
hits.length );
( (LuceneIndex) index ).nrtRelease( searcher );
}
//This simply checks whether there is a Rule Attribute "ruleflow-group" and a Rule Attribute Value "myRuleflowGroup"
//The specific query does not check that the Rule Attribute Value corresponds to the Rule Attribute, so it is possible
//that the value relates to a different Rule Attribute.
{
final IndexSearcher searcher = ( (LuceneIndex) index ).nrtSearcher();
final TopScoreDocCollector collector = TopScoreDocCollector.create( 10,
true );
final BooleanQuery query = new BooleanQuery();
query.add( new TermQuery( new Term( RuleAttributeIndexTerm.TERM,
"ruleflow-group" ) ),
BooleanClause.Occur.MUST );
query.add( new TermQuery( new Term( RuleAttributeValueIndexTerm.TERM,
"myruleflowgroup" ) ),
BooleanClause.Occur.MUST );
searcher.search( query,
collector );
final ScoreDoc[] hits = collector.topDocs().scoreDocs;
assertEquals( 1,
hits.length );
( (LuceneIndex) index ).nrtRelease( searcher );