Class FlexibleSearchQuery
The FlexibleSearchQuery stores all needed informations (the query itself, parameters, ...) to execute a search in the
FlexibleSearchService. This class provides possibility to write much more cleaner code than with manually
handling query and parameters.
...
final Map queryParams = new HashMap<String, Object>();
queryParams.put("value", Boolean.TRUE);
final FlexibleSearchQuery fQuery = new FlexibleSearchQuery("SELECT {PK} FROM {Language AS l} WHERE {l.active} = ?value ORDER BY {PK}", queryParams);
fQuery.
...
Please note that this class is not thread-safe and not intended to be living longer than one request.
-
Constructor Summary
ConstructorsConstructorDescriptionFlexibleSearchQuery(String query) FlexibleSearchQuery constructor.FlexibleSearchQuery constructor.FlexibleSearchQuery(String query, Map queryParams) FlexibleSearchQuery constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds hints to Flexible Search query.voidAdds hints to Flexible Search query.voidaddQueryParameter(String key, Object value) Add a query parameter to the search.voidaddQueryParameters(Map<String, ? extends Object> params) Add a additional parameter map (String->Object) to the search.booleangetHints()getQuery()inthashCode()toString()Methods inherited from class de.hybris.platform.servicelayer.search.AbstractQuery
getCatalogVersions, getCount, getLanguage, getLocale, getResultClassList, getSessionSearchRestrictions, getStart, getUser, isDisableCaching, isDisableSearchRestrictions, isDisableSpecificDbLimitSupport, isFailOnUnknownFields, isNeedTotal, isTypeExclusive, setCatalogVersions, setCatalogVersions, setCount, setDisableCaching, setDisableSearchRestrictions, setDisableSpecificDbLimitSupport, setFailOnUnknownFields, setLanguage, setLocale, setNeedTotal, setResultClassList, setSessionSearchRestrictions, setSessionSearchRestrictions, setStart, setTypeExclusive, setUser
-
Constructor Details
-
FlexibleSearchQuery
FlexibleSearchQuery constructor. The query is mandatory and contains the flexible search string. Search parameters can be set withaddQueryParameter(String, Object)/addQueryParameters(Map)or instead use the constructorFlexibleSearchQuery(String, Map).- Parameters:
query- the flexible search query
-
FlexibleSearchQuery
FlexibleSearchQuery constructor. The query is mandatory and contains the flexible search string builder. Search parameters can be set withaddQueryParameter(String, Object)/addQueryParameters(Map)or instead use the constructorFlexibleSearchQuery(String, Map).- Parameters:
sb- the StringBuilder object containing flexible search query
-
FlexibleSearchQuery
FlexibleSearchQuery constructor. This constructor is used when the flexible search string contains additional search parameter which are added by the queryParams parameter. The key of the map are referenced in the flexible search query by ?<key>- Parameters:
query- the flexible search queryqueryParams- a Map<String, Object> with the additional search parameters
-
-
Method Details
-
addHints
Adds hints to Flexible Search query.- Parameters:
hints-
-
addHints
Adds hints to Flexible Search query.- Parameters:
hints-
-
getHints
-
addQueryParameter
Add a query parameter to the search. The key is referenced in the query (see
getQuery()) with ?<key>Note that:
nullvalue is not legal parameters.
emptyCollectionvalue is not legal parameters.- Parameters:
key- the key of the parametervalue- the value of the parameter
-
addQueryParameters
Add a additional parameter map (String->Object) to the search. Each key is referenced in the query (see
getQuery()) with ?<key>Note that:
nullvalue inparamsmap is not legal.
emptyCollectionvalue inparamsmap is not legal.- Parameters:
params- the map
-
equals
-
getQuery
- Returns:
- the flexible search query. This is not the translated SQL query.
-
getQueryParameters
- Returns:
- all parameters for the search
-
hashCode
public int hashCode() -
toString
-