cancel
Showing results for 
Search instead for 
Did you mean: 

date facet 'buckets' with CE 5.0B

dbiggins
Star Contributor
Star Contributor
I am able to add additional attributes to the list of facet-able attributes in the search result list in Alfresco CE5.0 B through the search manager.  As long as the attributes are defined as indexed in the object model, everything works great.

The counts for single and repeating attribute counts appear to work as expected, and they appear to filter correctly.

I would like to have dates and datetime attributes handled in date "buckets" or ranges, in the same way that the create and modified dates are handled.  I can't get them to return in anything other then counts based on the full timestamp:

2014-01-16T05:00:00Z 10
2014-01-17T05:00:00Z 10
2014-01-24T05:00:00Z 10

How do we specify that the facets should be ranged results?  do we configure directly against the solr config for that, or through the share config?
4 REPLIES 4

afaust
Legendary Innovator
Legendary Innovator
Hello,

if you want a specific (custom) date property to have facet values grouped in buckets / ranges, you have to configure a specific handler on the Repository tier. Take a look at the sor-facets-context.xml how this is done for the cm:modified / cm:created facets and copy&paste&modify accordingly for your property.

<blockcode>
   <bean id="facet.dateBucketsDisplayHandler" class="org.alfresco.repo.search.impl.solr.facet.handler.DateBucketsDisplayHandler" parent="baseFacetLabelDisplayHandler" >
      <constructor-arg index="0">
         <set>
            <value>@{http://www.alfresco.org/model/content/1.0}created</value>
            <value>@{http://www.alfresco.org/model/content/1.0}modified</value>
         </set>
      </constructor-arg>
      <constructor-arg index="1">
         <bean class="org.springframework.beans.factory.config.MapFactoryBean">
            <property name="targetMapClass">
               <value>java.util.LinkedHashMap</value>
            </property>
            <property name="sourceMap">
               <map>
                  <!– Bucket => yesterday TO today –>
                  <entry key="[NOW/DAY-1DAY TO NOW/DAY+1DAY]" value="faceted-search.date.one-day.label" />
                  <!– Bucket => Last week TO today –>
                  <entry key="[NOW/DAY-7DAYS TO NOW/DAY+1DAY]" value="faceted-search.date.one-week.label" />
                  <!–  Bucket => Last month TO today –>
                  <entry key="[NOW/DAY-1MONTH TO NOW/DAY+1DAY]" value="faceted-search.date.one-month.label" />
                  <!–  Bucket => Last 6 months TO today –>
                  <entry key="[NOW/DAY-6MONTHS TO NOW/DAY+1DAY]" value="faceted-search.date.six-months.label" />
                  <!–  Bucket => Last year TO today –>
                  <entry key="[NOW/DAY-1YEAR TO NOW/DAY+1DAY]" value="faceted-search.date.one-year.label" />
               </map>
            </property>
         </bean>
      </constructor-arg>
   </bean>
</blockcode>

Regards
Axel

dbiggins
Star Contributor
Star Contributor
Fantastic!  Thanks very much!

HI Dbiggins,

  How did you manage to add custom facets to share? I am using 5.0-c version.

Thanks
Anil

afaust
Legendary Innovator
Legendary Innovator
Please check the <a href="http://docs.alfresco.com/5.0/concepts/filtered-search.html">documentation</a> on how to customize the faceted search experience.
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.