Class FieldDefinition
- java.lang.Object
-
- com.broadleafcommerce.search.api.domain.FieldDefinition
-
- All Implemented Interfaces:
Serializable
public class FieldDefinition extends Object implements Serializable
A field which can be indexed and searched by.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
FieldDefinition.FieldDefinitionBuilder
-
Field Summary
Fields Modifier and Type Field Description static long
serialVersionUID
-
Constructor Summary
Constructors Constructor Description FieldDefinition()
FieldDefinition(String id, String label, String indexableType, boolean multiValued, String propertyPath, boolean combined, String multiValuedCombinedPropertyRootPath, List<String> propertyPaths, String delimiter, String abbreviation, boolean translatable, List<FieldVariant> variants, boolean faceted, Facet facet, String facetVariantType, boolean sortable, SortOption sortOption, String sortVariantType, boolean searchable, List<FieldQuery> fieldQueries, Map<String,FieldVariant> fieldVariantMap)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static FieldDefinition.FieldDefinitionBuilder
builder()
protected boolean
canEqual(Object other)
boolean
equals(Object o)
String
getAbbreviation()
Short field name which will be used for request parameters for example in sorting and filtering, as well as response field names.String
getDelimiter()
If this is a combined field, this is the delimiter string which should separate the values found from the propertyPaths.Facet
getFacet()
The facet which is driven by this field.FieldVariant
getFacetVariant()
Retrieve theFieldVariant
to be used for faceting.String
getFacetVariantType()
The field variant type which should be faceted on.List<FieldQuery>
getFieldQueries()
Defines how this field should be queried by variants on particular query types.Map<String,FieldVariant>
getFieldVariantMap()
A map of each field variant type to the correspondingFieldVariant
.FieldVariant
getFilterVariant()
Retrieve theFieldVariant
to be used for filtering.String
getId()
The context ID of the field.String
getIndexableType()
The type to which this field belongs.String
getJsonPath()
Retrieve the JSON path to the property holding this field on an indexable object, if present.List<String>
getJsonPaths()
If this field is combined, retrieve the JSON path to the property holding the fields on an indexable object to be combined, if present.String
getLabel()
The label of the field, suitable for display.String
getMultiValuedCombinedPropertyRootPath()
For fields which are bothmultiValued
ANDcombined
, this will be path to the list containing the objects representing each value.String
getPropertyPath()
The JSON path of this field excluding the root prefix, "$.".List<String>
getPropertyPaths()
If this is a combined field, these are the JSON paths to the fields to be combined into the final value, excluding the root prefix, "$.".SortOption
getSortOption()
The sort option which is driven by this field.FieldVariant
getSortVariant()
Retrieve theFieldVariant
to be used for sorting.String
getSortVariantType()
The field variant type which should be sorted on.Map<String,FieldVariant>
getVariantMap()
Returns a lazily initialized map of each field variant type to the correspondingFieldVariant
.List<FieldVariant>
getVariants()
The specific typed variants for this field.int
hashCode()
boolean
isCombined()
Whether or not this field should be a combination of multiple path values.boolean
isFaceted()
Indicates if this field has a facet.boolean
isMultiValued()
Whether or not this field should contain a list of values.boolean
isSearchable()
Whether or not the search query should be applied to this field on search.boolean
isSortable()
Indicates if this field is sortable.boolean
isTranslatable()
Indicates if this field is translatable.void
setAbbreviation(String abbreviation)
Short field name which will be used for request parameters for example in sorting and filtering, as well as response field names.void
setCombined(boolean combined)
Whether or not this field should be a combination of multiple path values.void
setDelimiter(String delimiter)
If this is a combined field, this is the delimiter string which should separate the values found from the propertyPaths.void
setFacet(Facet facet)
The facet which is driven by this field.void
setFaceted(boolean faceted)
Indicates if this field has a facet.void
setFacetVariantType(String facetVariantType)
The field variant type which should be faceted on.void
setFieldQueries(List<FieldQuery> fieldQueries)
Defines how this field should be queried by variants on particular query types.void
setFieldVariantMap(Map<String,FieldVariant> fieldVariantMap)
A map of each field variant type to the correspondingFieldVariant
.void
setId(String id)
The context ID of the field.void
setIndexableType(String indexableType)
The type to which this field belongs.void
setLabel(String label)
The label of the field, suitable for display.void
setMultiValued(boolean multiValued)
Whether or not this field should contain a list of values.void
setMultiValuedCombinedPropertyRootPath(String multiValuedCombinedPropertyRootPath)
For fields which are bothmultiValued
ANDcombined
, this will be path to the list containing the objects representing each value.void
setPropertyPath(String propertyPath)
The JSON path of this field excluding the root prefix, "$.".void
setPropertyPaths(List<String> propertyPaths)
If this is a combined field, these are the JSON paths to the fields to be combined into the final value, excluding the root prefix, "$.".void
setSearchable(boolean searchable)
Whether or not the search query should be applied to this field on search.void
setSortable(boolean sortable)
Indicates if this field is sortable.void
setSortOption(SortOption sortOption)
The sort option which is driven by this field.void
setSortVariantType(String sortVariantType)
The field variant type which should be sorted on.void
setTranslatable(boolean translatable)
Indicates if this field is translatable.void
setVariants(List<FieldVariant> variants)
The specific typed variants for this field.String
toString()
-
-
-
Field Detail
-
serialVersionUID
public static final long serialVersionUID
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
FieldDefinition
public FieldDefinition(String id, String label, String indexableType, boolean multiValued, String propertyPath, boolean combined, String multiValuedCombinedPropertyRootPath, List<String> propertyPaths, String delimiter, String abbreviation, boolean translatable, List<FieldVariant> variants, boolean faceted, Facet facet, String facetVariantType, boolean sortable, SortOption sortOption, String sortVariantType, boolean searchable, List<FieldQuery> fieldQueries, Map<String,FieldVariant> fieldVariantMap)
-
FieldDefinition
public FieldDefinition()
-
-
Method Detail
-
getJsonPath
@Nullable public String getJsonPath()
Retrieve the JSON path to the property holding this field on an indexable object, if present.- Returns:
- propertyPath if present, prepended with "$."
-
getJsonPaths
public List<String> getJsonPaths()
If this field is combined, retrieve the JSON path to the property holding the fields on an indexable object to be combined, if present.- Returns:
- propertyPaths if present, prepended with "$."
-
getFilterVariant
@Nullable public FieldVariant getFilterVariant()
Retrieve theFieldVariant
to be used for filtering. Use Facet Variant if present, otherwise fall back to the first variant.- Returns:
- variant to be used for filtering, or null
-
getFacetVariant
@Nullable public FieldVariant getFacetVariant()
Retrieve theFieldVariant
to be used for faceting.- Returns:
- variant to be used for faceting, or null
-
getSortVariant
@Nullable public FieldVariant getSortVariant()
Retrieve theFieldVariant
to be used for sorting.- Returns:
- variant to be used for sorting, or null
-
getVariantMap
public Map<String,FieldVariant> getVariantMap()
Returns a lazily initialized map of each field variant type to the correspondingFieldVariant
. The map is constructed with the valueFieldVariant.getType()
as the key and theFieldVariant
as the value.- Returns:
- a map of each field variant type to the corresponding field variant
-
builder
public static FieldDefinition.FieldDefinitionBuilder builder()
-
getId
public String getId()
The context ID of the field.- Returns:
- the context ID of the field
-
getLabel
public String getLabel()
The label of the field, suitable for display.- Returns:
- label for the field, suitable for display
-
getIndexableType
public String getIndexableType()
The type to which this field belongs. Populated byIndexableType
type.- Returns:
- type to which this field belongs
-
isMultiValued
public boolean isMultiValued()
Whether or not this field should contain a list of values.- Returns:
- whether this field should contain a list of values
-
getPropertyPath
public String getPropertyPath()
The JSON path of this field excluding the root prefix, "$.". This is the path to the actual value that will be stored in the index, e.g. 'price', 'description', 'customer.name', etc.For more advanced mapping options, see the JSONPath documentation
- Returns:
- path to find field's value on indexable object
-
isCombined
public boolean isCombined()
Whether or not this field should be a combination of multiple path values. If true, then instead of propertyPath, the multi-valued propertyPaths will be used and joined with the delimiter.- Returns:
- whether this field should be a combination of multiple path values
-
getMultiValuedCombinedPropertyRootPath
public String getMultiValuedCombinedPropertyRootPath()
For fields which are bothmultiValued
ANDcombined
, this will be path to the list containing the objects representing each value. For example, to combine property paths for each category in a list of all categories in the object being indexed, this would becategories[*]
.- Returns:
- path to find multi-valued combined field's property path root list
-
getPropertyPaths
public List<String> getPropertyPaths()
If this is a combined field, these are the JSON paths to the fields to be combined into the final value, excluding the root prefix, "$.".For combined fields, all property paths should point to a single-valued object, the String value of which will be used.
For fields which are both
multiValued
ANDcombined
, the root for this path will be an individual object in the list defined by themultiValuedCombinedPropertyRootPath
. For example, if the indexable domain was:{ "categories": [ { "id": "exampleId", "name": "exampleName" } ] }
, and themultiValuedCombinedPropertyRootPath
wascategories[*]
, then the propertyPaths might beid
orname
.- Returns:
- path to find field's values on indexable object
-
getDelimiter
public String getDelimiter()
If this is a combined field, this is the delimiter string which should separate the values found from the propertyPaths.- Returns:
- separator for values combined form propertyPaths
-
getAbbreviation
public String getAbbreviation()
Short field name which will be used for request parameters for example in sorting and filtering, as well as response field names.- Returns:
- short name for request and response field name
-
isTranslatable
public boolean isTranslatable()
Indicates if this field is translatable.- Returns:
- whether this field is translatable
-
getVariants
public List<FieldVariant> getVariants()
The specific typed variants for this field.- Returns:
- specific typed variants for this field
-
isFaceted
public boolean isFaceted()
Indicates if this field has a facet.- Returns:
- whether this field has a facet
-
getFacet
public Facet getFacet()
The facet which is driven by this field.- Returns:
- facet driven by this field
-
getFacetVariantType
public String getFacetVariantType()
The field variant type which should be faceted on.If not provided, the first variant type will be used.
- Returns:
- the variant type which should be faceted on
-
isSortable
public boolean isSortable()
Indicates if this field is sortable.- Returns:
- whether this field is sortable
-
getSortOption
public SortOption getSortOption()
The sort option which is driven by this field.- Returns:
- sort driven by this field
-
getSortVariantType
public String getSortVariantType()
The field variant type which should be sorted on.If not provided, the first variant type will be used.
- Returns:
- the variant type which should be sorted on
-
isSearchable
public boolean isSearchable()
Whether or not the search query should be applied to this field on search.- Returns:
- should search query be applied on this field
-
getFieldQueries
public List<FieldQuery> getFieldQueries()
Defines how this field should be queried by variants on particular query types.- Returns:
- the variant level field queries
-
getFieldVariantMap
public Map<String,FieldVariant> getFieldVariantMap()
A map of each field variant type to the correspondingFieldVariant
. Populated bygetVariantMap()
.- Returns:
- map of each field variant type to the corresponding field variant
-
setId
public void setId(String id)
The context ID of the field.- Parameters:
id
- the context ID of the field
-
setLabel
public void setLabel(String label)
The label of the field, suitable for display.- Parameters:
label
- label for the field, suitable for display
-
setIndexableType
public void setIndexableType(String indexableType)
The type to which this field belongs. Populated byIndexableType
type.- Parameters:
indexableType
- type to which this field belongs
-
setMultiValued
public void setMultiValued(boolean multiValued)
Whether or not this field should contain a list of values.- Parameters:
multiValued
- whether this field should contain a list of values
-
setPropertyPath
public void setPropertyPath(String propertyPath)
The JSON path of this field excluding the root prefix, "$.". This is the path to the actual value that will be stored in the index, e.g. 'price', 'description', 'customer.name', etc.For more advanced mapping options, see the JSONPath documentation
- Parameters:
propertyPath
- path to find field's value on indexable object
-
setCombined
public void setCombined(boolean combined)
Whether or not this field should be a combination of multiple path values. If true, then instead of propertyPath, the multi-valued propertyPaths will be used and joined with the delimiter.- Parameters:
combined
- whether this field should be a combination of multiple path values
-
setMultiValuedCombinedPropertyRootPath
public void setMultiValuedCombinedPropertyRootPath(String multiValuedCombinedPropertyRootPath)
For fields which are bothmultiValued
ANDcombined
, this will be path to the list containing the objects representing each value. For example, to combine property paths for each category in a list of all categories in the object being indexed, this would becategories[*]
.- Parameters:
propertyPath
- path to find multi-valued combined field's property path root list
-
setPropertyPaths
public void setPropertyPaths(List<String> propertyPaths)
If this is a combined field, these are the JSON paths to the fields to be combined into the final value, excluding the root prefix, "$.".For combined fields, all property paths should point to a single-valued object, the String value of which will be used.
For fields which are both
multiValued
ANDcombined
, the root for this path will be an individual object in the list defined by themultiValuedCombinedPropertyRootPath
. For example, if the indexable domain was:{ "categories": [ { "id": "exampleId", "name": "exampleName" } ] }
, and themultiValuedCombinedPropertyRootPath
wascategories[*]
, then the propertyPaths might beid
orname
.- Parameters:
propertyPaths
- paths to find field's values on indexable object
-
setDelimiter
public void setDelimiter(String delimiter)
If this is a combined field, this is the delimiter string which should separate the values found from the propertyPaths.- Parameters:
delimiter
- separator for values combined form propertyPaths
-
setAbbreviation
public void setAbbreviation(String abbreviation)
Short field name which will be used for request parameters for example in sorting and filtering, as well as response field names.- Parameters:
abbreviation
- short name for request and response field name
-
setTranslatable
public void setTranslatable(boolean translatable)
Indicates if this field is translatable.- Parameters:
translatable
- whether this field is translatable
-
setVariants
public void setVariants(List<FieldVariant> variants)
The specific typed variants for this field.- Parameters:
variants
- specific typed variants for this field
-
setFaceted
public void setFaceted(boolean faceted)
Indicates if this field has a facet.- Parameters:
faceted
- whether this field has a facet
-
setFacet
public void setFacet(Facet facet)
The facet which is driven by this field.- Parameters:
facet
- facet driven by this field
-
setFacetVariantType
public void setFacetVariantType(String facetVariantType)
The field variant type which should be faceted on.If not provided, the first variant type will be used.
- Parameters:
facetVariantType
- the variant type which should be faceted on
-
setSortable
public void setSortable(boolean sortable)
Indicates if this field is sortable.- Parameters:
sortable
- whether this field is sortable
-
setSortOption
public void setSortOption(SortOption sortOption)
The sort option which is driven by this field.- Parameters:
sort
- sort driven by this field
-
setSortVariantType
public void setSortVariantType(String sortVariantType)
The field variant type which should be sorted on.If not provided, the first variant type will be used.
- Parameters:
sortVariantType
- the variant type which should be sorted on
-
setSearchable
public void setSearchable(boolean searchable)
Whether or not the search query should be applied to this field on search.- Parameters:
searchable
- should search query be applied on this field
-
setFieldQueries
public void setFieldQueries(List<FieldQuery> fieldQueries)
Defines how this field should be queried by variants on particular query types.- Parameters:
fieldQueries
- the variant level field queries
-
setFieldVariantMap
public void setFieldVariantMap(Map<String,FieldVariant> fieldVariantMap)
A map of each field variant type to the correspondingFieldVariant
. Populated bygetVariantMap()
.- Parameters:
fieldVariantMap
- map of each field variant type to the corresponding field variant
-
canEqual
protected boolean canEqual(Object other)
-
-