Class NxQueryBuilder


  • public class NxQueryBuilder
    extends Object
    Elasticsearch query builder for the Nuxeo ES api.
    Since:
    5.9.5
    • Field Detail

      • repositories

        protected final List<String> repositories
      • limit

        protected int limit
      • offset

        protected int offset
      • esQueryBuilder

        protected org.elasticsearch.index.query.QueryBuilder esQueryBuilder
      • fetchFromElasticsearch

        protected boolean fetchFromElasticsearch
      • searchOnAllRepo

        protected boolean searchOnAllRepo
      • selectFields

        protected String[] selectFields
      • selectFieldsAndTypes

        protected Map<String,​Type> selectFieldsAndTypes
      • returnsDocuments

        protected boolean returnsDocuments
      • esOnly

        protected boolean esOnly
      • highlightFields

        protected List<String> highlightFields
      • useUnrestrictedSession

        protected boolean useUnrestrictedSession
    • Constructor Detail

      • NxQueryBuilder

        public NxQueryBuilder​(CoreSession coreSession)
    • Method Detail

      • getAggregateFilterId

        public static String getAggregateFilterId​(Aggregate<?> agg)
      • limit

        public NxQueryBuilder limit​(int limit)
        No more than that many documents will be returned. Default to {DEFAULT_LIMIT}. Since Nuxeo 8.4 and ES 2.x, we can not give -1 to this method as the default configuration on ES allows to have a search window of 10000 documents at maximum. This settings could be changed on ES by changing {index.max_result_window}, but it is preferable to use the scan & scroll API.
      • offset

        public NxQueryBuilder offset​(int offset)
        Says to skip that many documents before beginning to return documents. If both offset and limit appear, then offset documents are skipped before starting to count the limit documents that are returned.
      • nxql

        public NxQueryBuilder nxql​(String nxql)
        Build the query from a NXQL string. You should either use nxql, either esQuery, not both.
      • esQuery

        public NxQueryBuilder esQuery​(org.elasticsearch.index.query.QueryBuilder queryBuilder)
        Build the query using the Elasticsearch QueryBuilder API. You should either use nxql, either esQuery, not both.
      • fetchFromElasticsearch

        public NxQueryBuilder fetchFromElasticsearch()
        Ask for the Elasticsearch _source field, use it to build documents.
      • hitDocConsumer

        public NxQueryBuilder hitDocConsumer​(EsFetcher.HitDocConsumer consumer)
        If search results are found, use this SearchHit and DocumentModel consumer on each hit.
        Since:
        10.2
      • useUnrestrictedSession

        public NxQueryBuilder useUnrestrictedSession​(boolean useUnrestrictedSession)
        Since:
        11.1
      • fetchFromDatabase

        public NxQueryBuilder fetchFromDatabase()
        Fetch the documents using VCS (database) engine. This is done by default
      • getLimit

        public int getLimit()
      • getOffset

        public int getOffset()
      • getNxql

        public String getNxql()
      • isFetchFromElasticsearch

        public boolean isFetchFromElasticsearch()
      • makeQuery

        public org.elasticsearch.index.query.QueryBuilder makeQuery()
        Get the Elasticsearch queryBuilder. Note that it returns only the query part without order, limits nor aggregates, use the udpateRequest to get the full request.
      • nxqlHasSelectClause

        protected boolean nxqlHasSelectClause​(String nxql)
      • getSortBuilders

        public org.elasticsearch.search.sort.SortBuilder<?>[] getSortBuilders()
      • guessFieldType

        protected String guessFieldType​(String field)
      • getAggregateFilter

        protected org.elasticsearch.index.query.QueryBuilder getAggregateFilter()
      • getAggregateFilterExceptFor

        protected org.elasticsearch.index.query.QueryBuilder getAggregateFilterExceptFor​(String id)
      • getEsAggregates

        public List<org.elasticsearch.search.aggregations.bucket.filter.FilterAggregationBuilder> getEsAggregates()
      • updateRequest

        public void updateRequest​(org.elasticsearch.search.builder.SearchSourceBuilder request)
      • addSecurityFilter

        protected org.elasticsearch.index.query.QueryBuilder addSecurityFilter​(org.elasticsearch.index.query.QueryBuilder query)
      • addSearchRepository

        public NxQueryBuilder addSearchRepository​(String repositoryName)
        Add a specific repository to search. Default search is done on the session repository only.
        Since:
        6.0
      • searchOnAllRepositories

        public NxQueryBuilder searchOnAllRepositories()
        Search on all available repositories.
        Since:
        6.0
      • getSearchRepositories

        public List<String> getSearchRepositories()
        Return the list of repositories to search, or an empty list to search on all available repositories;
        Since:
        6.0
      • getFetcher

        public Fetcher getFetcher​(org.elasticsearch.action.search.SearchResponse response,
                                  Map<String,​String> repoNames)
        Since:
        6.0
      • getSelectFields

        public String[] getSelectFields()
        Since:
        7.2
      • getSelectFieldsAndTypes

        public Map<String,​Type> getSelectFieldsAndTypes()
        Since:
        7.2
      • returnsDocuments

        public boolean returnsDocuments()
        Since:
        7.2
      • returnsRows

        public boolean returnsRows()