You can configure dimensions, dimension values, record properties,
and aggregate record properties to display in the misc-path of URLs. You can
also specify the order in which dimension and dimension values display. The
urlconfig.xml
file provides a simple and convenient
method for configuring these options.
The
navStateFormatter
bean invokes the
com.endeca.soleng.urlformatter.seo.SeoNavStateFormatter
class to define
dimLocationFormatters
for each dimension that you want
to configure.
Using the
dimLocationFormatters
defined in the
navStateFormatter
bean, you can configure URLs for
navigation pages to include dimension names, roots, ancestors, and dimension
value names in the misc-path of URLs for navigation pages.
For example, the following URL is for the navigation state Region > Napa:
http://localhost:8888/endeca_jspref/controller.jsp?&Ne=8&N=4294967160
By optimizing the URL, it can be formatted as follows:
http://localhost:8888/urlformatter_jspref/controller/Napa/_/N-1z141vc/Ne-8
The
navStateCanonicalizer
bean invokes the
com.endeca.soleng.urlformatter.seo.SeoNavStateCanonicalizer
to order the dimension and dimension value names included in the misc-path for
navigation pages. For example, an end user can reach the Wine Type > Red,
Region > Napa page by navigating first to Wine Type > Red and then to
Region > Napa, or by navigating to Region > Napa and then Wine Type >
Red. To avoid two syntactically different URLs for the same Wine Type > Red,
Region > Napa page, you can use the
navStateCanonicalizer
to standardize the order of
dimension and dimension values in the misc-path.
Note
By design, the URL optimization classes prevent the creation of syntactically different URLs by canonicalizing keywords. You can choose from a number of configuration options to control the arrangement of keywords, but the URLs are always canonicalized.
URL optimization for record detail pages is configured separately from
navigation pages and aggregate record details pages. The
erecFormatter
bean invokes the
com.endeca.soleng.urlformatter.seo.SeoERecFormatter
class to define
dimLocationFormatters
for each dimension that you want
to configure.
The same options for including dimension names, roots, ancestors, and
dimension value names are available for record detail pages as are available
for navigation pages. While the
urlconfig.xml
configuration file uses the same
dimLocationFormatters
for the
erecFormatter
and the
aggErecFormatter
as are used for the
navStateFormatter
, this is not a requirement. You can
create separate
dimLocationFormatters
for navigation pages, record
detail pages, and aggregate record detail pages.
URL optimization for aggregate record detail pages is configured
separately from navigation pages and record details pages as are available for
navigation pages. The
aggrERecFormatter
bean invokes the
com.endeca.soleng.urlformatter.seo.SeoAggrERecFormatter
class to define
dimLocationFormatters
for each dimension that you want
to configure. The same options for including dimension names, roots, ancestors,
a nd dimension value names are available for aggregate record detail pages.
While the
urlconfig.xml
configuration file uses the same
dimLocationFormatters
for the
aggrERecFormatter
and the
erecFormatter
as are used for the
navStateFormatter
, this is not a requirement. You can
create separate
dimLocationFormatters
for navigation pages, record
detail pages, and aggregate record detail pages.
The
SeoNavStateFormatter
,
SeoERecFormatter
, and
SeoAggrERecFormatter
use
StringFormatter
objects to format dimension and record
property strings that display in URLs.
You can format the strings in the misc-path section of a URL by using string formatters that are predefined in the Assembler API. Formatting may include changing capitalization or applying a regular expression to replace portions of the string.
There are several
StringFormatter
objects in the Assembler API:
LowerCaseStringFormatter
— formats path-keyword data into lower case.UpperCaseStringFormatter
— formats path-keyword data into upper case.RegexStringFormatter
— You can create a newRegexStringFormatter
object and customize thepattern
,replacement
, andreplaceAll
properties to perform custom string formatting. For more information about the properties, please refer to the Assembler API Reference (Javadoc).
To define
StringFormatter
objects in the
urlconfig.xml
file:
Create a bean to invoke a
StringFormatter
class.This example shows the configuration for a
RegexStringFormatter
that replaces all non-word character sequences with a single "-
" character:<bean class="com.endeca.soleng.urlformatter.seo.RegexStringFormatter"> <property name="pattern"> <value><![CDATA[[\W_&&[^\u00C0-\u00FF]]+]]></value> </property> <property name="replacement"> <value>-</value> </property> <property name="replaceAll"> <value>true</value> </property> </bean>
Optionally, you can build a
StringFormatterChain
to apply more than oneStringFormatter
to a string in series.The following example shows the
defaultStringFormatterChain
that is used throughout the sampleurlconfig.xml
file.<bean name="defaultStringFormatterChain" class="com.endeca.soleng.urlformatter.seo.StringFormatterChain"> <property name="stringFormatters"> <list> <!-- ############################################################## # replace all non-word character sequences with a single '-' # --> <bean class="com.endeca.soleng.urlformatter.seo.RegexStringFormatter"> <property name="pattern"> <value><![CDATA[[\W_&&[^\u00C0-\u00FF]]+]]></value> </property> <property name="replacement"> <value>-</value> </property> <property name="replaceAll"> <value>true</value> </property> </bean> <!-- ############################################################## # trim leading and trailing '-' characters (if any) # --> <bean class="com.endeca.soleng.urlformatter.seo.RegexStringFormatter"> <property name="pattern"> <value><![CDATA[^-?([\w\u00C0-\u00FF][\w-\u00C0-\u00FF]*[\w\u00C0-\u00FF])-?$]]></value> </property> <property name="replacement"> <value>$1</value> </property> <property name="replaceAll"> <value>false</value> </property> </bean> </list> </property> </bean>
Note that because
StringFormatterChain
implements
StringFormatter
, you can nest chains. For example:
<bean class="com.endeca.soleng.urlformatter.seo.StringFormatterChain"> <property name="stringFormatters"> <list> <!-- replace 'Wine Type' with 'Wine' --> <bean class="com.endeca.soleng.urlformatter.seo.RegexStringFormatter"> <property name="pattern"> <value>Wine Type</value> </property> <property name="replacement"> <value>Wine</value> </property> <property name="replaceAll"> <value>false</value> </property> </bean> <!-- execute the default string formatter chain --> <ref bean="defaultStringFormatterChain"/> </list> </property> </bean>
Using URL optimization, you can include dimension and dimension value names in the misc-path of URLs. You can also choose to canonicalize these dimension and dimension value names in order to avoid duplicate content and to increase your natural search rankings.
Note
For dimensions to display properly in the URL, they must be enabled for display with the record list.
You must create a URL configuration file before completing this procedure.
To optimize URLs for navigation pages:
Create a
navStateFormatter
bean to invoke thecom.endeca.soleng.urlformatter.seo.SeoNavStateFormatter
:For example:
<bean id="navStateFormatter" class="com.endeca.soleng.urlformatter.seo.SeoNavStateFormatter"> </bean>
Add a
navStateFormatter
property to your top-levelseoUrlFormatter
bean.For example:
<bean id="seoUrlFormatter" class="com.endeca.soleng.urlformatter.seo.SeoUrlFormatter"> <!-- additional elements deleted from this example --!> <property name="navStateFormatter"> <ref bean="navStateFormatter"/> </property> </bean>
Add a
useDimensionNameAsKey
property on thenavStateFormatter
.For example:
<bean id="navStateFormatter" class="com.endeca.soleng.urlformatter.seo.SeoNavStateFormatter"> <property name="useDimensionNameAsKey"> <value>true</value> </property> </bean>
Setting the
useDimensionNameAsKey
tofalse
creates a key on the dimension ID numbers.Add a
dimLocationFormatters
property and list eachdimLocationFormatter
bean you plan to define.For example:
<bean id="navStateFormatter" class="com.endeca.soleng.urlformatter.seo.SeoNavStateFormatter"> <property name="useDimensionNameAsKey"> <value>true</value> </property> <property name="dimLocationFormatters"> <list> <ref bean="wineTypeFormatter"/> <ref bean="regionFormatter"/> <ref bean="wineryFormatter"/> <ref bean="flavorsFormatter"/> </list> </property> </bean>
Create a
dimLocationFormatter
for each of the dimensions in thedimLocationFormatters
list.For example:
<bean id="regionFormatter" class="com.endeca.soleng.urlformatter.seo.SeoDimLocationFormatter"> </bean>
Note
The sample
urlconfig.xml
file uses the samedimLocationFormatter
for navigation pages, record detail pages, and aggregate record detail pages. You can choose to create uniquedimLocationFormatters
for each page type.Add the following properties to each
dimLocationFormatter
:Property Description key
In the navStateFormatter
bean, theuseDimensionNameAsKey
property sets the key type. If you set theuseDimensionNameAsKey
to true, then use the dimension name as the value for this property (for example<value>Region</value>
). If you set theuseDimensionNameAsKey
to false, use the dimension ID number.appendRoot
Specifies whether or not to append root dimension values to the URL. Set to true
to append root dimension values.appendAncestors
Specifices whether or not to append ancestor dimension values to the URL. Set to true
to append ancestor dimension values.appendDescriptor
Specifies whether or not to append the selected or descriptor dimension values to the URL. Set to true
to append selected or descriptor dimension values.separator
Specifies the character used to separate dimension roots, ancestors, and descriptor values. rootStringFormatter
Specifies the bean to format the dimension name. The reference application uses a defaultStringFormatterChain
bean to invoke thecom.endeca.soleng.urlformatter.seo.StringFormatterChain
.dimValStringFormatter
Specifies the bean to format the dimension value names. The reference application uses a defaultStringFormatterChain
bean to invoke thecom.endeca.soleng.urlformatter.seo.StringFormatterChain
. The examples below also use adefaultStringFormatterChain
bean.For example:
<bean id="regionFormatter" class="com.endeca.soleng.urlformatter.seo.SeoDimLocationFormatter"> <property name="key"> <value>Region</value> </property> <property name="appendRoot"> <value>false</value> </property> <property name="appendAncestors"> <value>false</value> </property> <property name="appendDescriptor"> <value>true</value> </property> <property name="separator"> <value>-</value> </property> <property name="rootStringFormatter"> <ref bean="defaultStringFormatterChain"/> </property> <property name="dimValStringFormatter"> <ref bean="defaultStringFormatterChain"/> </property> </bean>
Create a
navStateCanonicalizer
bean to invoke thecom.endeca.soleng.urlformatter.seo.SeoNavStateCanonicalizer
class.For example:
<bean name="navStateCanonicalizer" class="com.endeca.soleng.urlformatter.seo.SeoNavStateCanonicalizer"> </bean>
Note
Canonicalizing the dimension and dimension value names in the misc-path also changes the order in which they appear in the path-params section of the URL. For example, if Napa is configured to display before Red in the misc-path, the Napa dimension value ID displays before the Red dimension value ID in the path-params section.
Add a
navStateCanonicalizer
property to your top-levelseoUrlFormatter
bean.For example:
<bean id="seoUrlFormatter" class="com.endeca.soleng.urlformatter.seo.SeoUrlFormatter"> <!-- additional elements deleted from this example --!> <property name="navStateCanonicalizer"> <ref bean="navStateCanonicalizer"/> </property> </bean>
Configure the
navStateCanonicalizer
.For example, the following configuration creates URLs sorted by dimension ID in descending order:
<bean name="navStateCanonicalizer" class="com.endeca.soleng.urlformatter.seo.SeoNavStateCanonicalizer"> <property name="sortByName"> <value>false</value> </property> <property name="sortByDimension"> <value>true</value> </property> <property name="ascending"> <value>false</value> </property> </bean>
Note
There a number of possible configuration options for canonicalization.
You can customize the canonicalization of URLs for navigation pages by choosing a sort method, for example by dimension name or dimension ID, and then a sort direction.
The following example configurations use the dimensions:
and the dimension values:
Sort Direction |
Configuration |
Example base URL (sorted by dimension ID) |
---|---|---|
Ascending |
<property name="ascending"> <value>true</value> </property>
|
|
Descending |
<property name="ascending"> <value>false</value> </property>
|
|
Sort by |
Configuration |
Example base URL (sort direction ascending) |
---|---|---|
Dimension name, case sensitive |
<property name="sortByName"> <value>true</value> </property> <property name="sortByDimension"> <value>true</value> </property> <property name="ignoreCase"> <value>false</value> </property>
|
|
Dimension name, case insensitive |
<property name="sortByName"> <value>true</value> </property> <property name="sortByDimension"> <value>true</value> </property> <property name="ignoreCase"> <value>true</value> </property>
|
|
Dimension ID |
<property name="sortByName"> <value>false</value> </property> <property name="sortByDimension"> <value>true</value> </property>
|
|
Dimension value name, case sensitive |
<property name="sortByName"> <value>true</value> </property> <property name="sortByDimension"> <value>false</value> </property> <property name="ignoreCase"> <value>false</value> </property>
|
|
Dimension value name, case insensitive |
<property name="sortByName"> <value>true</value> </property> <property name="sortByDimension"> <value>false</value> </property> <property name="ignoreCase"> <value>true</value> </property>
|
|
Dimension value ID |
<property name="sortByName"> <value>false</value> </property> <property name="sortByDimension"> <value>false</value> </property>
|
|
Example 1: the following code sample creates a canonicalized URL that sorts by dimension name, case sensitive, in an ascending order:
<bean name="navStateCanonicalizer" class="com.endeca.soleng.urlformatter.seo.SeoNavStateCanonicalizer"> <property name="sortByName"> <value>true</value> </property> <property name="sortByDimension"> <value>true</value> </property> <property name="ascending"> <value>true</value> </property> <property name="ignoreCase"> <value>false</value> </property> </bean>
The resulting base URL:
http://localhost/urlformatter_jspref/controller/Wine-red/region-Napa/
Example 2: the following code sample creates a canonicalized URL that sorts by dimension value ID in a descending order:
<bean name="navStateCanonicalizer" class="com.endeca.soleng.urlformatter.seo.SeoNavStateCanonicalizer"> <property name="sortByName"> <value>false</value> </property> <property name="sortByDimension"> <value>true</value> </property> <property name="ascending"> <value>false</value> </property> </bean>
The resulting base URL:
http://localhost/urlformatter_jspref/controller/region-Napa/Wine-red/
Note
Canonicalizing the dimension and dimension value names in the misc-path changes the order in which they appear in the path-params section of the URL. For example, if Napa is configured to display before Red in the misc-path, the Napa dimension value ID displays before the Red dimension value ID in the path-params section.
Using the URL optimization classes, you can include dimension names, dimension value names, and record properties in the misc-path of URLs for record detail pages.
Note
For dimensions to display properly in the URL, they must be enabled for display with the record list.
You must create a URL configuration file before completing this procedure.
To optimize URLs for record detail pages:
Create an
erecFormatter
bean to invoke thecom.endeca.soleng.urlformatter.seo.SeoERecFormatter
:For example:
<bean id="erecFormatter" class="com.endeca.soleng.urlformatter.seo.SeoERecFormatter"> </bean>
Add an
ERecFormatter
property to your top-levelseoUrlFormatter
bean.For example:
<bean id="seoUrlFormatter" class="com.endeca.soleng.urlformatter.seo.SeoUrlFormatter"> <!-- additional elements deleted from this example --!> <property name="ERecFormatter"> <ref bean="erecFormatter"/> </property> </bean>
Add a
useDimensionNameAsKey
property on theerecFormatter
.For example:
<bean id="erecFormatter" class="com.endeca.soleng.urlformatter.seo.SeoERecFormatter"> <property name="useDimensionNameAsKey"> <value>true</value> </property> </bean>
Setting
useDimensionNameAsKey
tofalse
creates a key on the dimension ID numbers.Add a
propertyKeys
property to include record properties in the URLs of record details pages.For example:
<bean id="erecFormatter" class="com.endeca.soleng.urlformatter.seo.SeoERecFormatter"> <property name="useDimensionNameAsKey"> <value>true</value> </property> <property name="propertyKeys"> <list> <value>P_Name</value> </list> </property> </bean>
Add a
propertyFormatter
property to format record properties included in the URLs of record details pages.For example:
<bean id="erecFormatter" class="com.endeca.soleng.urlformatter.seo.SeoERecFormatter"> <property name="useDimensionNameAsKey"> <value>true</value> </property> <property name="propertyKeys"> <list> <value>P_Name</value> </list> </property> <property name="propertyFormatter"> <ref bean="defaultStringFormatterChain"/> </property> </bean>
Add a
dimLocationFormatters
property and list eachdimLocationFormatter
bean you plan to define.For example:
<bean id="erecFormatter" class="com.endeca.soleng.urlformatter.seo.SeoERecFormatter"> <property name="useDimensionNameAsKey"> <value>true</value> </property> <property name="dimLocationFormatters"> <list> <ref bean="regionFormatter"/> <ref bean="wineryFormatter"/> <ref bean="wineTypeFormatter"/> <ref bean="vintageFormatter"/> </list> </property> <property name="propertyKeys"> <list> <value>P_Name</value> </list> </property> <property name="propertyFormatter"> <ref bean="defaultStringFormatterChain"/> </property> </bean>
Create a
dimLocationFormatter
for each of the dimensions in thedimLocationFormatters
list.For example:
<bean id="regionFormatter" class="com.endeca.soleng.urlformatter.seo.SeoDimLocationFormatter"> </bean>
Note
The sample
urlconfig.xml
file uses the samedimLocationFormatter
for navigation pages, record detail pages, and aggregate record detail pages. You can choose to create uniquedimLocationFormatters
for each page type.Add the following properties to each
dimLocationFormatter
:Property Description key
In the navStateFormatter
bean, theuseDimensionNameAsKey
property sets the key type. If you set theuseDimensionNameAsKey
to true, then use the dimension name as the value for this property (for example<value>Region</value>
). If you set theuseDimensionNameAsKey
to false, use the dimension ID number.appendRoot
Specifies whether or not to append root dimension values to the URL. Set to true
to append root dimension values.appendAncestors
Specifices whether or not to append ancestor dimension values to the URL. Set to true
to append ancestor dimension values.appendDescriptor
Specifies whether or not to append the selected or descriptor dimension values to the URL. Set to true
to append selected or descriptor dimension values.separator
Specifies the character used to separate dimension roots, ancestors, and descriptor values. rootStringFormatter
Specifies the bean to format the dimension name. The reference application uses a defaultStringFormatterChain
bean to invoke thecom.endeca.soleng.urlformatter.seo.StringFormatterChain
.dimValStringFormatter
Specifies the bean to format the dimension value names. The reference application uses a defaultStringFormatterChain
bean to invoke thecom.endeca.soleng.urlformatter.seo.StringFormatterChain
. The examples below also use adefaultStringFormatterChain
bean.For example:
<bean id="regionFormatter" class="com.endeca.soleng.urlformatter.seo.SeoDimLocationFormatter"> <property name="key"> <value>Region</value> </property> <property name="appendRoot"> <value>false</value> </property> <property name="appendAncestors"> <value>false</value> </property> <property name="appendDescriptor"> <value>true</value> </property> <property name="separator"> <value>-</value> </property> <property name="rootStringFormatter"> <ref bean="defaultStringFormatterChain"/> </property> <property name="dimValStringFormatter"> <ref bean="defaultStringFormatterChain"/> </property> </bean>
Using the URL optimization classes, you can include dimension names, dimension value names, and record properties in the misc-path of URLs for aggregate record detail pages. These are configured separately from the optimizations for navigation pages.
Note
For dimensions to display properly in the URL, they must be enabled for display with the record list.
You must create a URL configuration file before completing this procedure.
To optimize URLs for aggregate record detail pages:
Create an
aggrERecFormatter
bean to invoke thecom.endeca.soleng.urlformatter.seo.SeoAggrERecFormatter
class:For example:
<bean id="aggrERecFormatter" class="com.endeca.soleng.urlformatter.seo.SeoAggrERecFormatter"> </bean>
Add an
aggrERecFormatter
property to your top-levelseoUrlFormatter
bean.For example:
<bean id="seoUrlFormatter" class="com.endeca.soleng.urlformatter.seo.SeoUrlFormatter"> <!-- additional elements deleted from this example --!> <property name="aggrERecFormatter"> <ref bean="aggrERecFormatter"/> </property> </bean>
Add a
useDimensionNameAsKey
property on theaggrERecFormatter
.For example:
<bean id="aggrERecFormatter" class="com.endeca.soleng.urlformatter.seo.SeoAggrERecFormatter"> <property name="useDimensionNameAsKey"> <value>true</value> </property> </bean>
Setting the
useDimensionNameAsKey
tofalse
creates a key on the dimension ID numbers.Add a
propertyKeys
property to include record properties in the URLs of record details pages.For example:
<bean id="aggrERecFormatter" class="com.endeca.soleng.urlformatter.seo.SeoAggrERecFormatter"> <property name="useDimensionNameAsKey"> <value>true</value> </property> <property name="propertyKeys"> <list> <value>P_Name</value> </list> </property> </bean>
Add a
propertyFormatter
property to format record properties included in the URLs of record details pages.For example:
<bean id="aggrERecFormatter" class="com.endeca.soleng.urlformatter.seo.SeoAggrERecFormatter"> <property name="useDimensionNameAsKey"> <value>true</value> </property> <property name="propertyKeys"> <list> <value>P_Name</value> </list> </property> <!-- use default string formatter chain --> <property name="propertyFormatter"> <ref bean="defaultStringFormatterChain"/> </property> </bean>
Add a
dimLocationFormatters
property and list eachdimLocationFormatter
bean you plan to define.For example:
<bean id="aggrERecFormatter" class="com.endeca.soleng.urlformatter.seo.SeoAggrERecFormatter"> <property name="useDimensionNameAsKey"> <value>true</value> </property> <property name="dimLocationFormatters"> <list> <ref bean="regionFormatter"/> <ref bean="wineryFormatter"/> </list> </property> <property name="propertyKeys"> <list> <value>P_Name</value> </list> </property> <property name="propertyFormatter"> <ref bean="defaultStringFormatterChain"/> </property> </bean>
Note
The sample
urlconfig.xml
file uses the samedimLocationFormatter
for navigation pages, record detail pages, and aggregate record detail pages. You can choose to create uniquedimLocationFormatters
for each page type.Create a
dimLocationFormatter
for each of the dimensions in thedimLocationFormatters
list.For example:
<bean id="regionFormatter" class="com.endeca.soleng.urlformatter.seo.SeoDimLocationFormatter"> </bean>
Add the following properties to each
dimLocationFormatter
:Property Description key
In the navStateFormatter
bean, theuseDimensionNameAsKey
property sets the key type. If you set theuseDimensionNameAsKey
to true, then use the dimension name as the value for this property (for example<value>Region</value>
). If you set theuseDimensionNameAsKey
to false, use the dimension ID number.appendRoot
Specifies whether or not to append root dimension values to the URL. Set to true
to append root dimension values.appendAncestors
Specifices whether or not to append ancestor dimension values to the URL. Set to true
to append ancestor dimension values.appendDescriptor
Specifies whether or not to append the selected or descriptor dimension values to the URL. Set to true
to append selected or descriptor dimension values.separator
Specifies the character used to separate dimension roots, ancestors, and descriptor values. rootStringFormatter
Specifies the bean to format the dimension name. The reference application uses a defaultStringFormatterChain
bean to invoke thecom.endeca.soleng.urlformatter.seo.StringFormatterChain
.dimValStringFormatter
Specifies the bean to format the dimension value names. The reference application uses a defaultStringFormatterChain
bean to invoke thecom.endeca.soleng.urlformatter.seo.StringFormatterChain
. The examples below also use adefaultStringFormatterChain
bean.For example:
<bean id="regionFormatter" class="com.endeca.soleng.urlformatter.seo.SeoDimLocationFormatter"> <property name="key"> <value>Region</value> </property> <property name="appendRoot"> <value>false</value> </property> <property name="appendAncestors"> <value>false</value> </property> <property name="appendDescriptor"> <value>true</value> </property> <property name="separator"> <value>-</value> </property> <property name="rootStringFormatter"> <ref bean="defaultStringFormatterChain"/> </property> <property name="dimValStringFormatter"> <ref bean="defaultStringFormatterChain"/> </property> </bean>