Class EnterpriseFulltextSearchBuilder
- All Implemented Interfaces:
FulltextSearchBuilder
-
Nested Class Summary
Nested classes/interfaces inherited from interface ch.tocco.nice2.persist.entity.api.fulltext.FulltextSearchBuilder
FulltextSearchBuilder.SearchScope
-
Constructor Summary
ConstructorDescriptionEnterpriseFulltextSearchBuilder
(List<FulltextSearchBuilderModifier> modifiers, org.slf4j.Logger logger, FulltextSearchBuilder sqlsearch, LocaleResolverService localeResolverService) -
Method Summary
Modifier and TypeMethodDescriptionbuild
(EntityModel queryEntityModel, @Nullable FulltextSearchBuilder.SearchScope searchScope, String searchInput, String fieldPath, FieldModel fieldModel, @Nullable EntityModel entityModel) build
(EntityModel rootModel, String searchInput, EntityModel targetModel, FulltextSearchBuilder.SearchScope searchScope) Appends criteria on the query to look for the given input on the fields configured on the entity for the corresponding SearchScope, for example 'fulltext'.build
(EntityModel rootModel, String searchInput, EntityModel targetModel, FulltextSearchBuilder.SearchScope searchScope, String fieldPrefix) Overloaded method with a fieldPrefix to use in the query.build
(EntityModel queryEntityModel, String searchInput, String fieldPath, FieldModel fieldModel) Appends criteria on the query to look for the given input in the field specified.build
(EntityModel queryEntityModel, String searchInput, Map<String, FieldModel> queryFields) Appends criteria on the query to look for the given input in the fields specified.build
(EntityModel queryEntityModel, String searchInput, Map<String, FieldModel> queryFields, @Nullable EntityModel entityModel) void
setDateSearchEnabled
(boolean dateSearchEnabled)
-
Constructor Details
-
EnterpriseFulltextSearchBuilder
public EnterpriseFulltextSearchBuilder(List<FulltextSearchBuilderModifier> modifiers, org.slf4j.Logger logger, FulltextSearchBuilder sqlsearch, LocaleResolverService localeResolverService)
-
-
Method Details
-
build
public Optional<Condition> build(EntityModel rootModel, String searchInput, EntityModel targetModel, FulltextSearchBuilder.SearchScope searchScope) Description copied from interface:FulltextSearchBuilder
Appends criteria on the query to look for the given input on the fields configured on the entity for the corresponding SearchScope, for example 'fulltext'.Example: You are building a query (eg "find Address") and need to join in a fulltext search on that same entity for a user specified search term (eg "8021 zurich").
See
class header
.- Specified by:
build
in interfaceFulltextSearchBuilder
- Parameters:
searchInput
- The user-provided fulltext search.targetModel
- The target entity to join- Returns:
true
if something was appended,false
if not (for example because the query terms were considered too short by all fields involved).
-
build
public Optional<Condition> build(EntityModel rootModel, String searchInput, EntityModel targetModel, FulltextSearchBuilder.SearchScope searchScope, String fieldPrefix) Description copied from interface:FulltextSearchBuilder
Overloaded method with a fieldPrefix to use in the query.This is the method to use when the targetModel is not the same as the main one used in the query
Example: You are building a query (eg "find User") and need to join in a fulltext search on a related entity (eg "Address") for a user specified search term (eg "8021 zurich").
See
class header
.- Specified by:
build
in interfaceFulltextSearchBuilder
- Parameters:
searchInput
- The user-provided fulltext search.targetModel
- The target entity to joinfieldPrefix
- Must end with a dot (the separator). Example: "myRelation."- Returns:
true
if something was appended,false
if not (for example because the query terms were considered too short by all fields involved).- See Also:
-
build
public Optional<Condition> build(EntityModel queryEntityModel, String searchInput, Map<String, FieldModel> queryFields) Description copied from interface:FulltextSearchBuilder
Appends criteria on the query to look for the given input in the fields specified. Example:
This means: all parts of the searchInput must occur in at least one of the fields. So:CriterionOrCloseBracket q = ...; FulltextSearchBuilder fsb = fulltextFactory.fulltext(); QueryStatementHolder builder = new QueryStatementHolder(q); Map<String, FieldModel> fieldsToSearch = new HashMap<String, FieldModel>(); fieldsToSearch.put("zip_c", addressEntityModel.getFieldByName("zip_c")); fieldsToSearch.put("city_c", addressEntityModel.getFieldByName("city_c")); if ( fsb.build( builder, "8021 zurich", fieldsToSearch ) ) { q = builder.getCriterion(); }
- all parts of searchInput are mandatory (AND search)
- it does not matter in which field(s) (fields joined with OR)
See
class header
.- Specified by:
build
in interfaceFulltextSearchBuilder
- Parameters:
queryEntityModel
- The model of the query you're buildingsearchInput
- The user-provided fulltext search.queryFields
- The fields to include in the search. The key is the path to the field, which may go through relations.- Returns:
true
if something was appended,false
if not (for example because the searchInput terms were considered too short by all fields involved).- See Also:
-
build
public Optional<Condition> build(EntityModel queryEntityModel, String searchInput, Map<String, FieldModel> queryFields, @Nullable @Nullable EntityModel entityModel) - Specified by:
build
in interfaceFulltextSearchBuilder
-
build
public Optional<Condition> build(EntityModel queryEntityModel, String searchInput, String fieldPath, FieldModel fieldModel) Description copied from interface:FulltextSearchBuilder
Appends criteria on the query to look for the given input in the field specified.Example:
CriterionOrCloseBracket q = ...; FulltextSearchBuilder fsb = fulltextFactory.fulltext(); QueryStatementHolder builder = new QueryStatementHolder(q); if ( fsb.build( builder, "zürich höngg", "relUser_Address.city_c", addressEntityModel.getFieldByName("city_c") ) ) { q = builder.getCriterion(); }
See
class header
.- Specified by:
build
in interfaceFulltextSearchBuilder
- Parameters:
searchInput
- The user-provided fulltext search.fieldPath
- The path to the field, may go through relations(s).fieldModel
- The field's model.- Returns:
true
if something was appended,false
if not (for example because the searchInput terms were considered too short by the field).- See Also:
-
build
public Optional<Condition> build(EntityModel queryEntityModel, @Nullable @Nullable FulltextSearchBuilder.SearchScope searchScope, String searchInput, String fieldPath, FieldModel fieldModel, @Nullable @Nullable EntityModel entityModel) - Specified by:
build
in interfaceFulltextSearchBuilder
- See Also:
-
setDateSearchEnabled
public void setDateSearchEnabled(boolean dateSearchEnabled)
-