Search in sources :

Example 1 with ListFilter

use of io.vertigo.dynamo.collections.ListFilter in project vertigo by KleeGroup.

the class DslListFilterBuilderTest method testStringFixedQuery.

private void testStringFixedQuery(final String[]... testData) {
    int i = 0;
    for (final String[] testParam : testData) {
        final ListFilter listFilter = createListFilterBuilder(String.class).withBuildQuery(testParam[0]).withCriteria(testParam[1]).build();
        final String result = listFilter.getFilterValue();
        final String expectedResult = testParam[Math.min(getPreferedResult(), testParam.length - 1)];
        Assert.assertEquals("Built query #" + i + " incorrect", expectedResult, result);
        i++;
    }
}
Also used : ListFilter(io.vertigo.dynamo.collections.ListFilter)

Example 2 with ListFilter

use of io.vertigo.dynamo.collections.ListFilter in project vertigo by KleeGroup.

the class DslListFilterBuilderTest method testObjectFixedQuery.

private void testObjectFixedQuery(final Object[]... testData) {
    int i = 0;
    for (final Object[] testParam : testData) {
        final ListFilter listFilter = createListFilterBuilder(Object.class).withBuildQuery((String) testParam[0]).withCriteria(testParam[1]).build();
        final String result = listFilter.getFilterValue();
        final Object expectedResult = testParam[Math.min(getPreferedResult(), testParam.length - 1)];
        Assert.assertEquals("Built query #" + i + " incorrect", expectedResult, result);
        i++;
    }
}
Also used : ListFilter(io.vertigo.dynamo.collections.ListFilter)

Example 3 with ListFilter

use of io.vertigo.dynamo.collections.ListFilter in project vertigo by KleeGroup.

the class RamLuceneQueryFactory method createFilteredQuery.

private static Query createFilteredQuery(final Analyzer queryAnalyser, final Query keywordsQuery, final List<ListFilter> filters) {
    final Builder queryBuilder = new BooleanQuery.Builder().add(keywordsQuery, BooleanClause.Occur.MUST);
    final StandardQueryParser queryParser = new StandardQueryParser(queryAnalyser);
    for (final ListFilter filter : filters) {
        try {
            queryBuilder.add(queryParser.parse(filter.getFilterValue(), null), isExclusion(filter) ? BooleanClause.Occur.MUST_NOT : BooleanClause.Occur.MUST);
        } catch (final QueryNodeException e) {
            throw WrappedException.wrap(e, "Erreur lors de la création du filtrage de la requete");
        }
    }
    return queryBuilder.build();
}
Also used : ListFilter(io.vertigo.dynamo.collections.ListFilter) QueryNodeException(org.apache.lucene.queryparser.flexible.core.QueryNodeException) BooleanQuery(org.apache.lucene.search.BooleanQuery) Builder(org.apache.lucene.search.BooleanQuery.Builder) Builder(org.apache.lucene.search.BooleanQuery.Builder) StandardQueryParser(org.apache.lucene.queryparser.flexible.standard.StandardQueryParser)

Example 4 with ListFilter

use of io.vertigo.dynamo.collections.ListFilter in project vertigo by KleeGroup.

the class AbstractSearchManagerTest method clean.

/**
 * @param indexDefinition Definition de l'index
 */
private void clean(final SearchIndexDefinition indexDefinition) {
    final ListFilter removeQuery = ListFilter.of("*:*");
    searchManager.removeAll(indexDefinition, removeQuery);
}
Also used : ListFilter(io.vertigo.dynamo.collections.ListFilter)

Example 5 with ListFilter

use of io.vertigo.dynamo.collections.ListFilter in project vertigo by KleeGroup.

the class SearchManagerMultiIndexTest method testClean.

/**
 * Test de création nettoyage de l'index.
 * La création s'effectue dans une seule transaction.
 */
@Test
public void testClean() {
    final DefinitionSpace definitionSpace = getApp().getDefinitionSpace();
    final SearchIndexDefinition carIndexDefinition = definitionSpace.resolve(IDX_CAR, SearchIndexDefinition.class);
    final SearchIndexDefinition carDynIndexDefinition = definitionSpace.resolve(IDX_DYNA_CAR, SearchIndexDefinition.class);
    final ListFilter removeQuery = ListFilter.of("*:*");
    searchManager.removeAll(carIndexDefinition, removeQuery);
    searchManager.removeAll(carDynIndexDefinition, removeQuery);
    waitIndexation();
    final long sizeCar = query("*:*", carIndexDefinition);
    Assert.assertEquals(0, sizeCar);
    final long sizeCarDyn = query("*:*", carDynIndexDefinition);
    Assert.assertEquals(0, sizeCarDyn);
}
Also used : ListFilter(io.vertigo.dynamo.collections.ListFilter) SearchIndexDefinition(io.vertigo.dynamo.search.metamodel.SearchIndexDefinition) DefinitionSpace(io.vertigo.core.definition.DefinitionSpace) Test(org.junit.Test)

Aggregations

ListFilter (io.vertigo.dynamo.collections.ListFilter)16 FacetValue (io.vertigo.dynamo.collections.model.FacetValue)3 DefinitionSpace (io.vertigo.core.definition.DefinitionSpace)2 MessageText (io.vertigo.core.locale.MessageText)2 SearchIndexDefinition (io.vertigo.dynamo.search.metamodel.SearchIndexDefinition)2 HashMap (java.util.HashMap)2 QueryNodeException (org.apache.lucene.queryparser.flexible.core.QueryNodeException)2 StandardQueryParser (org.apache.lucene.queryparser.flexible.standard.StandardQueryParser)2 BooleanQuery (org.apache.lucene.search.BooleanQuery)2 Builder (org.apache.lucene.search.BooleanQuery.Builder)2 Test (org.junit.Test)2 FacetDefinition (io.vertigo.dynamo.collections.metamodel.FacetDefinition)1 DtField (io.vertigo.dynamo.domain.metamodel.DtField)1 DtList (io.vertigo.dynamo.domain.model.DtList)1 DtObject (io.vertigo.dynamo.domain.model.DtObject)1 ArrayList (java.util.ArrayList)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1