Copyright© 2008-2018 SiteVision AB, all rights reserved.
@Requireable(value="FilterBuilder") public interface FilterBuilder extends Builder<Filter>
Builder for creating a Filter
component with specific behaviour.
FilterBuilder has one mandatory attribute:
Using the FilterBuilder is pretty straightforward, if you remember that it is stateful. Conceptually you would typically use it like this:
When you have built a Filter
instance, you can re-use the FilterBuilder to build more instances. Typically like:
Example of how this strategy could be implemented in Velocity:
## Get the builder
#set ($searchFactory = $sitevisionUtils.searchFactory)
#set ($filterBuilder = $searchFactory.FilterBuilder)
## Create a Filter
#set ($nameMustStartWithAndersFilter = $filterBuilder.addFilterQuery('+name:Anders*').build())
## Re-use the builder to create another Filter
#set ($nameMustContainMagnusFilter = $filterBuilder.clearFilterQueries().addFilterQuery('+name.analyzed:magnus*').build())
Tip! The Builder interface documentation
contains
more information about Builders and how to work with them!
An instance of the SiteVision class implementing this interface can be obtained via
SearchFactory.getFilterBuilder()
.
See SearchFactory
for how to obtain an instance of the SearchFactory
interface.
Modifier and Type | Method and Description |
---|---|
FilterBuilder |
addFilterQuery(String aFilterQuery)
Adds a filter query.
|
Filter |
build()
Creates a Filter component instance using currently specified state/behaviour.
|
FilterBuilder |
clearFilterQueries()
Removes all previously added filter queries.
|
FilterBuilder addFilterQuery(String aFilterQuery)
Solr note: this is the 'fq' param
Query syntax note! Query strings should be expressed according to the Solr query syntax.
The syntax is basically the
Lucene query syntax
with some minor differences.
Also note that a general recommendation is to always use the prefix operators (+
/-
) instead of the
boolean keywords (AND/OR/NOT) to avoid unexpected behaviour. For deeper understanding, see for example
Why Not AND, OR, And NOT?.
aFilterQuery
- the filter query, a null
or whitespace-only value will be ignoredFilterBuilder clearFilterQueries()
SiteVision - Portal and Content Management Made Easy
SiteVision is an advanced Java enterprise portal product and a portlet container (JSR 286) that implements Java Content Repository (JSR 283).
Copyright© 2008-2018 SiteVision AB, all rights reserved.