Search in sources :

Example 1 with SharedPartIndexTerm

use of org.kie.workbench.common.services.refactoring.model.index.terms.SharedPartIndexTerm in project drools-wb by kiegroup.

the class IndexRuleAttributeNameAndValueTest method testIndexDrlRuleAttributeNameAndValue.

@Test
public void testIndexDrlRuleAttributeNameAndValue() throws IOException, InterruptedException {
    // Add test files
    final Path path = basePath.resolve("drl1.drl");
    final String drl = loadText("drl1.drl");
    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();
        queryBuilder.add(new TermQuery(new Term((new SharedPartIndexTerm(PartType.RULEFLOW_GROUP)).getTerm())), BooleanClause.Occur.MUST);
        queryBuilder.add(new TermQuery(new Term("nonexistent")), BooleanClause.Occur.MUST);
        searchFor(index, queryBuilder.build(), 0);
    }
    // This note replaces an earlier note, if it doesn't make sense, delete or ignore it.
    // Both pieces of info (that it's a ruleflow group, and that the ruleflow group is called "myruleflowgroup")
    // are present in the same field ("shared:ruleflowgroup" => "myruleflowgroup"), so this only returns
    // documents that match that field (as opposed to the structure we had before).
    {
        final BooleanQuery.Builder queryBuilder = new BooleanQuery.Builder();
        ValueIndexTerm termVals = new ValueSharedPartIndexTerm("myruleflowgroup", PartType.RULEFLOW_GROUP);
        queryBuilder.add(new TermQuery(new Term(termVals.getTerm(), termVals.getValue())), BooleanClause.Occur.MUST);
        searchFor(index, queryBuilder.build(), 1);
    }
}
Also used : Path(org.uberfire.java.nio.file.Path) ValueSharedPartIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueSharedPartIndexTerm) BooleanQuery(org.apache.lucene.search.BooleanQuery) TermQuery(org.apache.lucene.search.TermQuery) ValueSharedPartIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueSharedPartIndexTerm) SharedPartIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.SharedPartIndexTerm) ValueIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueIndexTerm) Term(org.apache.lucene.index.Term) ValueSharedPartIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueSharedPartIndexTerm) SharedPartIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.SharedPartIndexTerm) ValueIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueIndexTerm) Test(org.junit.Test) BaseIndexingTest(org.kie.workbench.common.services.refactoring.backend.server.BaseIndexingTest)

Aggregations

Term (org.apache.lucene.index.Term)1 BooleanQuery (org.apache.lucene.search.BooleanQuery)1 TermQuery (org.apache.lucene.search.TermQuery)1 Test (org.junit.Test)1 BaseIndexingTest (org.kie.workbench.common.services.refactoring.backend.server.BaseIndexingTest)1 SharedPartIndexTerm (org.kie.workbench.common.services.refactoring.model.index.terms.SharedPartIndexTerm)1 ValueIndexTerm (org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueIndexTerm)1 ValueSharedPartIndexTerm (org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueSharedPartIndexTerm)1 Path (org.uberfire.java.nio.file.Path)1