Package fr.gouv.vitam.common.database.translators.elasticsearch

# Class QueryToElasticsearch

java.lang.Object
fr.gouv.vitam.common.database.translators.elasticsearch.QueryToElasticsearch

public class QueryToElasticsearch extends Object
Elasticsearch Translator

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static void`
  `addRoots(co.elastic.clients.elasticsearch._types.query_dsl.BoolQuery.Builder query, String field, Collection<String> roots, int depth)`
  `static co.elastic.clients.elasticsearch._types.query_dsl.Query`
  `getCommand(Query query, VarNameAdapter adapter, DynamicParserTokens parserTokens)`
  `static Map<String,co.elastic.clients.elasticsearch._types.aggregations.Aggregation>`
  `getFacets(AbstractParser<?> requestParser, DynamicParserTokens parserTokens)`
  Create ES facets from request parser
  `static co.elastic.clients.elasticsearch._types.query_dsl.Query`
  `getFullCommand(co.elastic.clients.elasticsearch._types.query_dsl.Query command, co.elastic.clients.elasticsearch._types.query_dsl.Query roots)`
  Merge a request and a root filter
  `static co.elastic.clients.elasticsearch._types.query_dsl.Query`
  `getRoots(String field, Collection<String> roots)`
  `static List<co.elastic.clients.elasticsearch._types.SortOptions>`
  `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

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Method Details

  - ### getRoots

    public static co.elastic.clients.elasticsearch._types.query_dsl.Query getRoots(String field, Collection<String> roots)
    Parameters:
      `field` - String
      `roots` - Set of String
    Returns:
      the filter associated with the roots

  - ### addRoots

    public static void addRoots(co.elastic.clients.elasticsearch._types.query_dsl.BoolQuery.Builder query, String field, Collection<String> roots, int depth)
    Parameters:
      `query` -
      `field` - String
      `roots` - Set of String

  - ### getFullCommand

    public static co.elastic.clients.elasticsearch._types.query_dsl.Query getFullCommand(co.elastic.clients.elasticsearch._types.query_dsl.Query command, co.elastic.clients.elasticsearch._types.query_dsl.Query roots)
    Merge a request and a root filter
    Parameters:
      `command` - QueryBuilder
      `roots` - QueryBuilder
    Returns:
      the complete request

  - ### getSorts

    public static List<co.elastic.clients.elasticsearch._types.SortOptions> 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 parser
      `score` - True will add score first
      `parserTokens` -
    Returns:
      list of order by as sort objects

  - ### getCommand

    public static co.elastic.clients.elasticsearch._types.query_dsl.Query getCommand(Query query, VarNameAdapter adapter, DynamicParserTokens parserTokens) throws InvalidParseOperationException
    Parameters:
      `query` - Query
      `parserTokens` -
    Returns:
      the associated QueryBuilder
    Throws:
      `InvalidParseOperationException` - if query could not parse to command

  - ### getFacets

    public static Map<String,co.elastic.clients.elasticsearch._types.aggregations.Aggregation> 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