Class QueryToElasticsearch
- java.lang.Object
-
- fr.gouv.vitam.common.database.translators.elasticsearch.QueryToElasticsearch
-
public class QueryToElasticsearch extends java.lang.ObjectElasticsearch Translator
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidaddRoots(org.elasticsearch.index.query.BoolQueryBuilder query, java.lang.String field, java.util.Collection<java.lang.String> roots, int depth)static org.elasticsearch.index.query.QueryBuildergetCommand(Query query, VarNameAdapter adapter, DynamicParserTokens parserTokens)static java.util.List<org.elasticsearch.search.aggregations.AggregationBuilder>getFacets(AbstractParser<?> requestParser, DynamicParserTokens parserTokens)Create ES facets from request parserstatic org.elasticsearch.index.query.QueryBuildergetFullCommand(org.elasticsearch.index.query.QueryBuilder command, org.elasticsearch.index.query.QueryBuilder roots)Merge a request and a root filterstatic org.elasticsearch.index.query.QueryBuildergetRoots(java.lang.String field, java.util.Collection<java.lang.String> roots)static java.util.List<org.elasticsearch.search.sort.SortBuilder<?>>getSorts(AbstractParser<?> requestParser, boolean score, DynamicParserTokens parserTokens)Generate sort list from order by ES query orders : {field1 : -1, field2 : 1} or [{field1 : -1, field2 : 1},{field3 : -1}]
Note : if the query contains a match and the collection allows to use score, the socre is added to the sort
-
-
-
Method Detail
-
getRoots
public static org.elasticsearch.index.query.QueryBuilder getRoots(java.lang.String field, java.util.Collection<java.lang.String> roots)- Parameters:
field- Stringroots- Set of String- Returns:
- the filter associated with the roots
-
addRoots
public static void addRoots(org.elasticsearch.index.query.BoolQueryBuilder query, java.lang.String field, java.util.Collection<java.lang.String> roots, int depth)- Parameters:
query-field- Stringroots- Set of String
-
getFullCommand
public static org.elasticsearch.index.query.QueryBuilder getFullCommand(org.elasticsearch.index.query.QueryBuilder command, org.elasticsearch.index.query.QueryBuilder roots)Merge a request and a root filter- Parameters:
command- QueryBuilderroots- QueryBuilder- Returns:
- the complete request
-
getSorts
public static java.util.List<org.elasticsearch.search.sort.SortBuilder<?>> getSorts(AbstractParser<?> requestParser, boolean score, DynamicParserTokens parserTokens)
Generate sort list from order by ES query orders : {field1 : -1, field2 : 1} or [{field1 : -1, field2 : 1},{field3 : -1}]
Note : if the query contains a match and the collection allows to use score, the socre is added to the sort
- Parameters:
requestParser- the original parserscore- True will add score firstparserTokens-- Returns:
- list of order by as sort objects
-
getCommand
public static org.elasticsearch.index.query.QueryBuilder getCommand(Query query, VarNameAdapter adapter, DynamicParserTokens parserTokens) throws InvalidParseOperationException
- Parameters:
query- QueryparserTokens-- Returns:
- the associated QueryBuilder
- Throws:
InvalidParseOperationException- if query could not parse to command
-
getFacets
public static java.util.List<org.elasticsearch.search.aggregations.AggregationBuilder> getFacets(AbstractParser<?> requestParser, DynamicParserTokens parserTokens) throws InvalidParseOperationException
Create ES facets from request parser- Parameters:
requestParser- parser- Returns:
- list of facets
- Throws:
InvalidParseOperationException- if could not create ES facets
-
-