Class AbstractSearchQuery
java.lang.Object
org.opencastproject.elasticsearch.impl.AbstractSearchQuery
- All Implemented Interfaces:
SearchQuery
- Direct Known Subclasses:
EventSearchQuery,SeriesSearchQuery,ThemeSearchQuery
Base implementation for search queries.
-
Field Summary
FieldsModifier and TypeFieldDescriptionThe list of fields to returnprotected StringFilter termsprotected booleanTrue if the search text should be matched using wildcardsprotected intThe query limitprotected intThe query offsetprotected List<SearchTerms<String>> Query termsThe document types -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCreates a search query that is executed on all document types.AbstractSearchQuery(String documentType) Creates a search query that is executed on the given document type. -
Method Summary
Modifier and TypeMethodDescriptionString[]Returns the fields that should be returned by the query.Returns the filter expression.intgetLimit()Returns the number of results that are returned, starting at the offset returned bygetOffset().intReturns the starting offset within the search result or0if no offset was specified.Returns the search text ornullif no text was specified.getSortOrder(String field) Returns the sort order of a field.Returns all the known sort orders.getTerms()Returns the search terms or an empty collection if no terms were specified.String[]getTypes()Returns the document types or or an empty array if no types were specified.booleanReturnstrueif the current search operation should be performed using fuzzy searching.protected abstract StringsortOrderFieldName(String field) Adds a field that needs to be returned by the query.withFields(String... fields) Adds the fields that need to be returned by the query.withFilter(String filter) Returns documents that match the search query and the text filter.withLimit(int limit) Sets the number of results that are returned.withOffset(int offset) Sets the starting offset.withSortOrder(String field, SortCriterion.Order order) Sort the result set by the field and the given order.Returns documents that contain the given text.withText(boolean wildcardSearch, SearchTerms.Quantifier quantifier, String... text) Returns documents that contain the given text.Returns documents that contain the given text.Return documents of the given types.
-
Field Details
-
types
The document types -
fields
The list of fields to return -
fuzzySearch
protected boolean fuzzySearchTrue if the search text should be matched using wildcards -
text
Query terms -
filter
Filter terms -
offset
protected int offsetThe query offset -
limit
protected int limitThe query limit
-
-
Constructor Details
-
AbstractSearchQuery
protected AbstractSearchQuery()Creates a search query that is executed on all document types. -
AbstractSearchQuery
Creates a search query that is executed on the given document type.- Parameters:
documentType- the document type
-
-
Method Details
-
withTypes
Description copied from interface:SearchQueryReturn documents of the given types.- Specified by:
withTypesin interfaceSearchQuery- Parameters:
types- the resource types to look up- Returns:
- the query extended by this criterion
-
getTypes
Description copied from interface:SearchQueryReturns the document types or or an empty array if no types were specified.- Specified by:
getTypesin interfaceSearchQuery- Returns:
- the type
-
withField
Description copied from interface:SearchQueryAdds a field that needs to be returned by the query. If no fields are being set, all fields will be returned.- Specified by:
withFieldin interfaceSearchQuery- Parameters:
field- the field name- Returns:
- the query
-
withFields
Description copied from interface:SearchQueryAdds the fields that need to be returned by the query. If no fields are being set, all fields will be returned.- Specified by:
withFieldsin interfaceSearchQuery- Parameters:
fields- the field names- Returns:
- the query
-
getFields
Description copied from interface:SearchQueryReturns the fields that should be returned by the query. If all fields should be returned, the method will return an empty array.- Specified by:
getFieldsin interfaceSearchQuery- Returns:
- the names of the fields to return
-
withLimit
Description copied from interface:SearchQuerySets the number of results that are returned.- Specified by:
withLimitin interfaceSearchQuery- Parameters:
limit- the number of results- Returns:
- the search query
-
getLimit
public int getLimit()Description copied from interface:SearchQueryReturns the number of results that are returned, starting at the offset returned bygetOffset(). If no limit was specified, this method returns-1.- Specified by:
getLimitin interfaceSearchQuery- Returns:
- the maximum number of results
-
withOffset
Description copied from interface:SearchQuerySets the starting offset. Search results will be returned starting at that offset and until the limit is reached, as specified bygetLimit().- Specified by:
withOffsetin interfaceSearchQuery- Parameters:
offset- the starting offset- Returns:
- the search query
-
getOffset
public int getOffset()Description copied from interface:SearchQueryReturns the starting offset within the search result or0if no offset was specified.- Specified by:
getOffsetin interfaceSearchQuery- Returns:
- the offset
-
withText
Description copied from interface:SearchQueryReturns documents that contain the given text.- Specified by:
withTextin interfaceSearchQuery- Parameters:
text- the text to look up- Returns:
- the query extended by this criterion
-
withText
Description copied from interface:SearchQueryReturns documents that contain the given text.- Specified by:
withTextin interfaceSearchQuery- Parameters:
wildcardSearch-Trueto perform a (much slower) wildcard searchtext- the text to look up- Returns:
- the query extended by this criterion
-
withText
public SearchQuery withText(boolean wildcardSearch, SearchTerms.Quantifier quantifier, String... text) Description copied from interface:SearchQueryReturns documents that contain the given text.Depending on the quantifier, either documents are returned that contain at least one of the terms are only documents containing all of the terms.
- Specified by:
withTextin interfaceSearchQuery- Parameters:
wildcardSearch-trueto perform a fuzzy searchquantifier- whether all or some of the terms need to be matchedtext- the text to look up- Returns:
- the query extended by this criterion
-
getTerms
Description copied from interface:SearchQueryReturns the search terms or an empty collection if no terms were specified.- Specified by:
getTermsin interfaceSearchQuery- Returns:
- the terms
-
getQueryString
Description copied from interface:SearchQueryReturns the search text ornullif no text was specified.- Specified by:
getQueryStringin interfaceSearchQuery- Returns:
- the text
-
isFuzzySearch
public boolean isFuzzySearch()Description copied from interface:SearchQueryReturnstrueif the current search operation should be performed using fuzzy searching.- Specified by:
isFuzzySearchin interfaceSearchQuery- Returns:
trueif fuzzy search should be used
-
withFilter
Description copied from interface:SearchQueryReturns documents that match the search query and the text filter.- Specified by:
withFilterin interfaceSearchQuery- Parameters:
filter- the filter text- Returns:
- the search query
-
getFilter
Description copied from interface:SearchQueryReturns the filter expression.- Specified by:
getFilterin interfaceSearchQuery- Returns:
- the filter
-
withSortOrder
Description copied from interface:SearchQuerySort the result set by the field and the given order. The insertion-order is kept.- Specified by:
withSortOrderin interfaceSearchQuery- Parameters:
field- the field name, must not benullorder- the order direction, must not benull- Returns:
- the updated search query
-
getSortOrders
Description copied from interface:SearchQueryReturns all the known sort orders. The insertion-order is kept.- Specified by:
getSortOrdersin interfaceSearchQuery- Returns:
- a map with all known sort orders
-
getSortOrder
Description copied from interface:SearchQueryReturns the sort order of a field. If no sort order has been set for the given field,SortCriterion.Order.Noneis returned.- Specified by:
getSortOrderin interfaceSearchQuery- Parameters:
field- the field name, must not benull- Returns:
- the sort order
-
sortOrderFieldName
-