Interface SearchService
- All Known Implementing Classes:
DefaultSearchService
Query objects which contain the search criteria in JIRA.- Since:
- v4.0
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final classstatic final class -
Method Summary
Modifier and TypeMethodDescriptionbooleandoesQueryFitFilterForm(ApplicationUser user, Query query) Checks if aQueryis capable of being shown on the simple (GUI-based) issue navigator edit screen.getGeneratedJqlString(Query query) Generates a JQL string representation for the passed query.Returns the URL relative to the app context to represent the specified issue search.getJqlString(Query query) Gets the JQL string representation for the passed query.getQueryContext(ApplicationUser searcher, Query query) Generates a full QueryContext for the specifiedQueryfor the searching user.getQueryString(ApplicationUser user, Query query) Deprecated.Since v7.1.getSearchContext(ApplicationUser searcher, Query query) This produces an old-styleSearchContextbased on the passed in search query and the user that is performing the search.getSimpleQueryContext(ApplicationUser searcher, Query query) Generates a simple QueryContext for the specifiedQueryfor the searching user.parseQuery(ApplicationUser searcher, String query) Parses the query string into a JQLQuery.sanitiseSearchQuery(ApplicationUser searcher, Query query) Returns an equivalentQuerywith all the potential "information leaks" removed, with regards to the specified user.search(DocumentSearchRequest searchRequest, PagerFilter pager) Searches the index and returns issues within the pager's range.search(ApplicationUser searcher, Query jqlQuery, Query filterQuery, TrackHits trackHits, PagerFilter pager) Searches the index and returns issues within the pager's range.search(ApplicationUser searcher, Query jqlQuery, Query filterQuery, PagerFilter pager) Searches the index and returns issues within the pager's range.search(ApplicationUser searcher, Query query, TrackHits trackHits, PagerFilter pager) Search the index, and only return issues that are in the pager's range.search(ApplicationUser searcher, Query query, PagerFilter pager) Search the index, and only return issues that are in the pager's range.longsearchCount(ApplicationUser searcher, Query query) Search the index, and return the count of the issues matching the query.longsearchCount(ApplicationUser searcher, Query query, Long timeout) Search the index, and return the count of the issues matching the query.longsearchCountOverrideSecurity(ApplicationUser searcher, Query query) Return the number of issues matching the provided search criteria, overridding any security constraints.searchOverrideSecurity(ApplicationUser searcher, Query query, PagerFilter pager) Search the index, and only return issues that are in the pager's range not taking into account any security constraints.streamSearch(ApplicationUser searcher, Query query) Search the index, and only return the matched issues as a stream, which is memory efficient for a large number of issues.validateQuery(ApplicationUser searcher, Query query) Validates the specifiedQueryfor passed user.validateQuery(ApplicationUser searcher, Query query, Long searchRequestId) Validates the specifiedQueryfor passed user and search request.
-
Method Details
-
search
SearchResults<Issue> search(ApplicationUser searcher, Query query, PagerFilter pager) throws SearchException Search the index, and only return issues that are in the pager's range.Note: that this method returns read only
Issueobjects, and should not be used where you need the issue for update.- Parameters:
searcher- the user performing the search, which will be used to create a permission filter that filters out any of the results the user is not able to see and will be used to provide context for the search.query- contains the information required to perform the search.pager- the pager filter. To retrieve unlimited number of results, usestreamSearch(com.atlassian.jira.user.ApplicationUser, com.atlassian.query.Query)- Returns:
- A
SearchResultscontaining the resulting issues. - Throws:
SearchException- thrown if there is a severe problem encountered with lucene when searching (wraps an IOException).- Since:
- v7.0
-
search
SearchResults<Issue> search(ApplicationUser searcher, Query query, @Nullable TrackHits trackHits, PagerFilter pager) throws SearchException Search the index, and only return issues that are in the pager's range.Note: that this method returns read only
Issueobjects, and should not be used where you need the issue for update.- Parameters:
searcher- the user performing the search, which will be used to create a permission filter that filters out any of the results the user is not able to see and will be used to provide context for the search.query- contains the information required to perform the search.trackHits- defines how the total hits count is calculated. Only applicable forSearchPlatform.OPENSEARCH. ForSearchPlatform.LUCENEthe total hits count is always tracked (equivalent toTrackHits.all()).pager- the pager filter. To retrieve unlimited number of results, usestreamSearch(com.atlassian.jira.user.ApplicationUser, com.atlassian.query.Query)- Returns:
- A
SearchResultscontaining the resulting issues. - Throws:
SearchException- thrown if there is a severe problem encountered with lucene when searching (wraps an IOException).- Since:
- 11.0
- See Also:
-
search
SearchResults<Issue> search(ApplicationUser searcher, Query jqlQuery, Query filterQuery, PagerFilter pager) throws SearchException Searches the index and returns issues within the pager's range. Allows adding a filter query (filterQuery) to merge with the JQL query (jqlQuery).Note that this method returns read only
Issueobjects, and should not be used where you need the issue for update.- Parameters:
searcher- the user performing the search, providing context for the search.jqlQuery- the JQL query to search with.filterQuery- an additional search query to combine with the generated query from the providedjqlQuery.pager- the pager filter. To retrieve unlimited number of results, usestreamSearch(com.atlassian.jira.user.ApplicationUser, com.atlassian.query.Query)- Returns:
- A
SearchResultscontaining the resulting issues. - Throws:
SearchException- if a severe problem is encountered during the search (wraps an IOException).- Since:
- 10.4
-
search
SearchResults<Issue> search(ApplicationUser searcher, Query jqlQuery, Query filterQuery, @Nullable TrackHits trackHits, PagerFilter pager) throws SearchException Searches the index and returns issues within the pager's range. Allows adding a filter query (filterQuery) to merge with the JQL query (jqlQuery).Note that this method returns read only
Issueobjects, and should not be used where you need the issue for update.- Parameters:
searcher- the user performing the search, providing context for the search.jqlQuery- the JQL query to search with.filterQuery- an additional search query to combine with the generated query from the providedjqlQuery.trackHits- defines how the total hits count is calculated. Only applicable forSearchPlatform.OPENSEARCH. ForSearchPlatform.LUCENEthe total hits count is always tracked (equivalent toTrackHits.all()).pager- the pager filter. To retrieve unlimited number of results, usestreamSearch(com.atlassian.jira.user.ApplicationUser, com.atlassian.query.Query)- Returns:
- A
SearchResultscontaining the resulting issues. - Throws:
SearchException- if a severe problem is encountered during the search (wraps an IOException).- Since:
- 11.0
- See Also:
-
search
SearchResults<Issue> search(DocumentSearchRequest searchRequest, PagerFilter pager) throws SearchException Searches the index and returns issues within the pager's range. Allows adding a filter query (filterQuery) to merge with the JQL query (jqlQuery).Note that this method returns read only
Issueobjects, and should not be used where you need the issue for update.- Parameters:
searchRequest- the set of parameters that define the search behaviourpager- the pager filter. To retrieve unlimited number of results, usestreamSearch(com.atlassian.jira.user.ApplicationUser, com.atlassian.query.Query)- Returns:
- A
SearchResultscontaining the resulting issues. - Throws:
SearchException- if a severe problem is encountered during the search (wraps an IOException).- Since:
- 11.2
- See Also:
-
streamSearch
SearchStreamResults<Issue> streamSearch(ApplicationUser searcher, Query query) throws SearchException Search the index, and only return the matched issues as a stream, which is memory efficient for a large number of issues.Note: that this method returns read only
Issueobjects, and should not be used where you need the issue for update.- Parameters:
searcher- the user performing the search, which will be used to create a permission filter that filters out any of the results the user is not able to see and will be used to provide context for the search.query- contains the information required to perform the search.- Returns:
- A
SearchStreamResultscontaining the stream of resulting issues. - Throws:
SearchException- thrown if there is a severe problem encountered when searching (wraps an IOException).- Since:
- v10.6
-
searchOverrideSecurity
SearchResults<Issue> searchOverrideSecurity(ApplicationUser searcher, Query query, PagerFilter pager) throws SearchException Search the index, and only return issues that are in the pager's range not taking into account any security constraints.As the method name implies, it bypasses the security restrictions that would normally be applied when performing a search. As such, it should only be used for administrative tasks where you really need to know about ALL affected issues.
Note that this method returns read only
Issueobjects, and should not be used where you need the issue for update. Also note that if you are only after the number of search results usesearchCount(ApplicationUser, Query)as it provides better performance.- Parameters:
searcher- the user performing the search which will be used to provide context for the search.query- contains the information required to perform the search.pager- the pager filter. To retrieve unlimited number of results, usestreamSearch(com.atlassian.jira.user.ApplicationUser, com.atlassian.query.Query)- Returns:
- A
SearchResultscontaining the resulting issues. - Throws:
SearchException- thrown if there is a severe problem encountered with lucene when searching (wraps an IOException).ClauseTooComplexSearchException- if the query or part of the query produces lucene that is too complex to be processed.- Since:
- v7.0
-
searchCount
Search the index, and return the count of the issues matching the query.- Parameters:
searcher- the user performing the search, which will be used to create a permission filter that filters out any of the results the user is not able to see and will be used to provide context for the search.query- contains the information required to perform the search.- Returns:
- the number of issues matching the query
- Throws:
SearchException- thrown if there is a severe problem encountered with lucene when searching (wraps an IOException).- Since:
- v7.0
-
searchCount
Search the index, and return the count of the issues matching the query.- Parameters:
searcher- the user performing the search, which will be used to create a permission filter that filters out any of the results the user is not able to see and will be used to provide context for the searchquery- contains the information required to perform the search.timeout- timeout in milliseconds- Returns:
- the number of issues matching the query
- Throws:
SearchException- thrown if there is a severe problem encountered with lucene when searching (wraps an IOException).- Since:
- v8.12
-
searchCountOverrideSecurity
Return the number of issues matching the provided search criteria, overridding any security constraints.As the method name implies, it bypasses the security restrictions that would normally be applied when performing a search. As such, it should only be used for administrative tasks where you really need to know about ALL affected issues.
Note: Searching for the count avoids loading the issue data into memory, so this should be preferred when the count is all you need to know.
- Parameters:
searcher- the user performing the search which will be used to provide context for the search.query- contains the information required to perform the search.- Returns:
- number of matching results.
- Throws:
SearchException- thrown if there is a severe problem encountered with lucene when searching (wraps an IOException).ClauseTooComplexSearchException- if the query or part of the query produces lucene that is too complex to be processed.- Since:
- v7.0
-
getQueryString
Deprecated.Returns the query string to represent the specified SearchQuery.The query string is prepended with "
&jqlQuery=" so that it is ready for use in building a URL.- Parameters:
user- the user performing the searchquery- the SearchQuery to generate the query string of. Does not accept null.- Returns:
- a String which represents the query string of a SearchQuery (ie no context/base applied). Never null.
- Since:
- v7.0 with ApplicationUser, previously with User
-
getIssueSearchPath
@Nonnull String getIssueSearchPath(ApplicationUser user, @Nonnull SearchService.IssueSearchParameters params) Returns the URL relative to the app context to represent the specified issue search.The URL is composed by the issue search path and provided parameters (e.g. "
&/issues/?jql=...invalid input: '&filter'=..."), but does NOT include the context path.- Parameters:
user- the user performing the searchparams- the parameters to generate the URL. Possible parameters are filter Id and query (JQL), both are optional but you cannot use both at the same time. Does not accept null.- Returns:
- a String which represents the issue search URL and query string corresponding to the parameters (no context/base applied). Never null.
- Since:
- v7.1
-
parseQuery
Parses the query string into a JQLQuery.- Parameters:
searcher- the user in contextquery- the query to parse into aQuery.- Returns:
- a result set that contains the query and a message set of any errors or warnings that occured during the parse.
- Since:
- v7.0
-
validateQuery
Validates the specifiedQueryfor passed user. The same as callingvalidateQuery(searcher, query, null);.- Parameters:
searcher- the user performing the searchquery- the search query to validate- Returns:
- a message set containing any errors encountered; never null.
- Since:
- v7.0
-
validateQuery
@Nonnull MessageSet validateQuery(ApplicationUser searcher, @Nonnull Query query, Long searchRequestId) Validates the specifiedQueryfor passed user and search request. This validates the the passed query as if it was run as the passed search request.- Parameters:
searcher- the user performing the search.query- the search query to validate.searchRequestId- validate in the context of this search request. Can be null to indicate the passed query is not currently a search request.- Returns:
- a message set containing any errors encountered; never null.
- Since:
- v7.0
-
doesQueryFitFilterForm
Checks if aQueryis capable of being shown on the simple (GUI-based) issue navigator edit screen.- Parameters:
user- the user who is executing the query.query- the Query which to check that is displayable on the simple (GUI-based) issue navigator edit screen. Does not accept null.- Returns:
- true if the query is displayable on the simple (GUI-based) issue navigator edit screen, false otherwise.
- Since:
- v7.0
-
getQueryContext
Generates a full QueryContext for the specifiedQueryfor the searching user. The full QueryContext contains all explicit and implicitly specified projects and issue types from the Query.For a better explanation of the differences between the full and simple QueryContexts, see
QueryContextVisitorinjira-core.- Parameters:
searcher- the user performing the searchquery- the search query to generate the context for- Returns:
- a QueryContext that contains the implicit and explicit project / issue types implied by the included clauses in the query.
- Since:
- v7.0
-
getSimpleQueryContext
Generates a simple QueryContext for the specifiedQueryfor the searching user. The simple QueryContext contains only the explicit projects and issue types specified in the Query. If none were specified, it will be the Global context.For a better explanation of the differences between the full and simple QueryContexts, see
QueryContextVisitorinjira-core.- Parameters:
searcher- the user performing the searchquery- the search query to generate the context for- Returns:
- a QueryContext that contains only the explicit project / issue types from the included clauses in the query.
- Since:
- v7.0
-
getSearchContext
This produces an old-styleSearchContextbased on the passed in search query and the user that is performing the search.This will only make sense if the query returns true for
doesQueryFitFilterForm(ApplicationUser, Query)since SearchContext is only relevant for simple queries.The more acurate context can be gotten by calling
getQueryContext(ApplicationUser, Query).If the query will not fit in the simple issue navigator then the generated SearchContext will be empty. This method never returns a null SearchContext, even when passed a null SearchQuery.
- Parameters:
searcher- the user performing the search, not always the SearchRequest's ownerquery- the query for which you want a context- Returns:
- a SearchContext with the correct project/issue types if the query fits in the issue navigator, otherwise an empty SearchContext. Never null.
- Since:
- v7.0
-
getJqlString
Gets the JQL string representation for the passed query. Returns the string fromQuery.getQueryString()if it exists or generates one if it does not. Equilavent to:if (query.getQueryString() != null) return query.getQueryString(); else return getGeneratedJqlString(query);- Parameters:
query- the query. Cannot be null.- Returns:
- the JQL string represenation of the passed query.
-
getGeneratedJqlString
Generates a JQL string representation for the passed query. The JQL string is always generated, that is,Query.getQueryString()is completely ignored if it exists. The returned JQL is automatically escaped as necessary.- Parameters:
query- the query. Cannot be null.- Returns:
- the generated JQL string representation of the passed query.
-
sanitiseSearchQuery
Returns an equivalentQuerywith all the potential "information leaks" removed, with regards to the specified user. For example, if the query contains the clause "project = Invisible", and the specified user does not have browse permission for project "Invisible", the sanitised query will replace this clause with "project = 12345" (where 12345 is the id of the project).- Parameters:
searcher- the user performing the searchquery- the query to sanitise; must not be null.- Returns:
- the sanitised query; never null.
- Since:
- v7.0
-