Issue:
How do I change the order of Date Facets? As example from top to bottom 'Today', 'Last Week', 'Last Month' instead of 'Last Month', 'Last Week', 'Today'.
Environment:
AppStudio
Resolution:
For the AppStudio Version prior to 4.7.0:
Step 1:
Create processor : processors.response.replaceCommasDateBuckets.conf with below details
name: twigkit.search.processors.response.ReplaceFilterValue
facetNames: lastModified_dt
replace: ,
with: to
Step 2:
Create another processor : processors.response.dateBucketFacetMapping.conf with the details below:
name: twigkit.search.processors.response.FacetFilterValueMappingProcessor facetNames: lastModified_dt mappings: [NOW/MONTH-6MONTHtoNOW]=Past 6 Months,[NOW/MONTH-1MONTHtoNOW]=Past Month,[NOW/DAY-7DAYtoNOW]=Past Week,[NOW/DAY-1DAYtoNOW]=Today
Step 3 :
Add above two processor in workflow of platform.fusion.fusion.conf
workflow: processors.response.replaceCommasDateBuckets,processors.response.dateBucketFacetMapping
So your fusion.conf will look like :
name: twigkit.search.fusion.Fusion backwardsCompatible: true timeOut: 30000 resultIDField: id highlight: true defaultQuery: *:* workflow: processors.response.replaceCommasDateBuckets,processors.response.dateBucketFacetMapping
Step 4:
Sample code search.html
<search:query var="query" parameters="*" results-per-page="12" fields="id" facets="lastModified_dt"> <query:custom name="facet.interval" value="{!ex=lastModified_dt}lastModified_dt"></query:custom> <query:custom name="f.lastModified_dt.facet.interval.set" value="[NOW/DAY-1DAY,NOW]"></query:custom> <query:custom name="f.lastModified_dt.facet.interval.set" value="[NOW/DAY-7DAY,NOW]"></query:custom> <query:custom name="f.lastModified_dt.facet.interval.set" value="[NOW/MONTH-1MONTH,NOW]"></query:custom> <query:custom name="f.lastModified_dt.facet.interval.set" value="[NOW/MONTH-6MONTH,NOW]"></query:custom> <query:custom name="facet.mincount" value="1"></query:custom> </search:query>
Step 5:
Build the project(mvn clean followed by mvn install)
Step 6:
Run the app(mvn jetty:run )
Step 7:
Following you can see the Output:
For the AppStudio Version 4.7.0:
Step 1:
An attribute that changes "," to "to" is no more required in 4.7.0, refer: https://doc.lucidworks.com/release-notes/appkit/4.7.0-release-notes.html#bug-fixes
Hence remove processors.response.replaceCommasDateBuckets from platform's workflow. So fusion.conf will have a workflow of:
workflow: processors.response.dateBucketFacetMapping
So that your fusion.conf will look like:
name: twigkit.search.fusion.Fusion
backwardsCompatible: true
timeOut: 30000
resultIDField: id
highlight: true
defaultQuery: *:*
workflow: processors.response.dateBucketFacetMapping
Step 2:
Then change the processors.response.dateBucketFacetMapping as below:
name: twigkit.search.processors.response.FacetFilterValueMappingProcessor facetNames: lastModified_dt mappings: [NOW/MONTH-6MONTH,NOW]=Last 6 Months;[NOW/MONTH-1MONTH,NOW]=Last Month;[NOW/DAY-7DAY,NOW]=Last Week;[NOW/DAY-1DAY,NOW]=Today separator: ;
Step 3:
You should see output like the below screenshot:
Comments
0 comments
Article is closed for comments.