Search in sources :

Example 6 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 7 with ListFilter

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

the class FacetFactory method createTermCluster.

private static <D extends DtObject> Map<FacetValue, DtList<D>> createTermCluster(final FacetDefinition facetDefinition, final DtList<D> dtList) {
    // map résultat avec les docs par FacetFilter
    final Map<FacetValue, DtList<D>> clusterValues = new LinkedHashMap<>();
    // Cas des facettes par Term
    final DtField dtField = facetDefinition.getDtField();
    // on garde un index pour incrémenter le facetFilter pour chaque Term
    final Map<Object, FacetValue> facetFilterIndex = new HashMap<>();
    FacetValue facetValue;
    for (final D dto : dtList) {
        final Object value = dtField.getDataAccessor().getValue(dto);
        facetValue = facetFilterIndex.get(value);
        if (facetValue == null) {
            final String valueAsString = dtField.getDomain().valueToString(value);
            final String label;
            if (StringUtil.isEmpty(valueAsString)) {
                label = "<==no label==>";
            } else {
                label = valueAsString;
            }
            final MessageText labelMsg = MessageText.of(label);
            // on garde la syntaxe Solr pour l'instant
            final ListFilter listFilter = ListFilter.of(dtField.getName() + ":\"" + valueAsString + "\"");
            facetValue = new FacetValue(label, listFilter, labelMsg);
            facetFilterIndex.put(value, facetValue);
            clusterValues.put(facetValue, new DtList<D>(dtList.getDefinition()));
        }
        clusterValues.get(facetValue).add(dto);
    }
    // tri des facettes
    final Comparator<FacetValue> facetComparator = new FacetComparator<>(clusterValues);
    final Map<FacetValue, DtList<D>> sortedFacetValues = new TreeMap<>(facetComparator);
    sortedFacetValues.putAll(clusterValues);
    return sortedFacetValues;
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) MessageText(io.vertigo.core.locale.MessageText) TreeMap(java.util.TreeMap) LinkedHashMap(java.util.LinkedHashMap) DtField(io.vertigo.dynamo.domain.metamodel.DtField) ListFilter(io.vertigo.dynamo.collections.ListFilter) FacetValue(io.vertigo.dynamo.collections.model.FacetValue) DtObject(io.vertigo.dynamo.domain.model.DtObject) DtList(io.vertigo.dynamo.domain.model.DtList)

Example 8 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 9 with ListFilter

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

the class SearchManagerStoreTest method doRemove.

private void doRemove(final String query) {
    final ListFilter removeQuery = ListFilter.of(query);
    searchManager.removeAll(itemIndexDefinition, removeQuery);
}
Also used : ListFilter(io.vertigo.dynamo.collections.ListFilter)

Example 10 with ListFilter

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

the class AbstractSearchManagerTest method doRemove.

private void doRemove(final String query) {
    final ListFilter removeQuery = ListFilter.of(query);
    searchManager.removeAll(carIndexDefinition, removeQuery);
}
Also used : ListFilter(io.vertigo.dynamo.collections.ListFilter)

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