001/* 002 * (C) Copyright 2014 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * tdelprat 018 * bdelbosc 019 */ 020 021package org.nuxeo.elasticsearch.api; 022 023import org.elasticsearch.index.query.QueryBuilder; 024import org.nuxeo.ecm.core.api.CoreSession; 025import org.nuxeo.ecm.core.api.DocumentModelList; 026import org.nuxeo.ecm.core.api.SortInfo; 027import org.nuxeo.elasticsearch.query.NxQueryBuilder; 028 029/** 030 * Interface to search on documents 031 * 032 * @since 5.9.3 033 */ 034public interface ElasticSearchService { 035 036 /** 037 * Returns a document list using an {@link NxQueryBuilder}. 038 * 039 * @since 5.9.5 040 */ 041 DocumentModelList query(NxQueryBuilder queryBuilder); 042 043 /** 044 * Returns documents and aggregates. 045 * 046 * @since 6.0 047 */ 048 EsResult queryAndAggregate(NxQueryBuilder queryBuilder); 049 050 /** 051 * Performs the initial search of a scrollable search request using an {@link NxQueryBuilder}. 052 * 053 * @param queryBuilder 054 * @param keepAlive the search context lifetime 055 * @return an {@link EsScrollResult} including the search results and a scroll id, to be passed to the subsequent 056 * calls to {@link #scroll(EsScrollResult)} 057 * @since 8.3 058 */ 059 EsScrollResult scroll(NxQueryBuilder queryBuilder, long keepAlive); 060 061 /** 062 * Performs the initial search of a scan-and-scroll search request using an {@link NxQueryBuilder}. 063 * 064 * @param queryBuilder 065 * @param keepAlive the search context lifetime 066 * @return an {@link EsScrollResult} including the search results and a scroll id, to be passed to the subsequent 067 * calls to {@link #scroll(EsScrollResult)} 068 * @since 8.3 069 */ 070 EsScrollResult scanAndScroll(NxQueryBuilder queryBuilder, long keepAlive); 071 072 /** 073 * Retrieves the next batch of results of a scrollable search request for the given {@link EsScrollResult}. 074 * 075 * @return an {@link EsScrollResult} including the search results and a scroll id, to be passed to the subsequent 076 * calls to {@link #scroll(EsScrollResult)} 077 * @since 8.3 078 */ 079 EsScrollResult scroll(EsScrollResult scrollResult); 080 081 /** 082 * Returns a document list using an NXQL query. Fetch documents from the VCS repository. 083 * 084 * @since 5.9.3 085 * @deprecated since 6.0, use query with NxQueryBuilder 086 */ 087 @Deprecated 088 DocumentModelList query(CoreSession session, String nxql, int limit, int offset, SortInfo... sortInfos); 089 090 /** 091 * Returns a document list using an ElasticSearch {@link QueryBuilder}. Fetch documents from the VCS repository. 092 * 093 * @since 5.9.3 094 * @deprecated since 6.0, use query with NxQueryBuilder 095 */ 096 @Deprecated 097 DocumentModelList query(CoreSession session, QueryBuilder queryBuilder, int limit, int offset, 098 SortInfo... sortInfos); 099 100}