Class QueryToElasticsearch


  • public class QueryToElasticsearch
    extends java.lang.Object
    Elasticsearch Translator
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void addRoots​(org.elasticsearch.index.query.BoolQueryBuilder query, java.lang.String field, java.util.Collection<java.lang.String> roots, int depth)  
      static org.elasticsearch.index.query.QueryBuilder getCommand​(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 parser
      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
      static org.elasticsearch.index.query.QueryBuilder getRoots​(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

      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getRoots

        public static org.elasticsearch.index.query.QueryBuilder getRoots​(java.lang.String field,
                                                                          java.util.Collection<java.lang.String> roots)
        Parameters:
        field - String
        roots - 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 - String
        roots - 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 - QueryBuilder
        roots - 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 parser
        score - True will add score first
        parserTokens -
        Returns:
        list of order by as sort objects