04-12-2019 05:46 AM
Hi,
I would like to get a different label for a facet, than the property value returned by default by the Search API.
I'm using the Alfresco Public Rest API Search Service for an ADF application, with facets.
The labels of the facets are returned by the API with the following schema :
"facetsFields": [ { "label": "string", "buckets": [ { "label": "string", "filterQuery": "string", "count": 0, "display": {} } ] } ],
The content of the "label" property is the value of the property in the contentstore by default. There is also a "display" property, which is used for a custom display ("Display name" for users-based buckets for example)
Within the source code, we can see that the "display" field is computed through a PropertyLookupRegistry, that registers custom PropertyLookup for some properties, like for example to return user "displayName" instead of its "username" (PersonPropertyLookup).
I've thus tried to create my custom PropertyLookup for my custom properties, and register it in my module context, by overriding the publicapi.propertyLookups bean.
<bean id="publicapi.myPropertyLookup" class="my.Class">
<property name="supported">
<list>
<value>my:property</value>
</list>
</property>
</bean><bean id="publicapi.propertyLookups" class="org.alfresco.rest.api.lookups.PropertyLookupRegistry">
<property name="lookups">
<list>
<ref bean="publicapi.personPropertyLookup" />
<ref bean="publicapi.mimeTypePropertyLookup" />
<ref bean="publicapi.myPropertyLookup"/>
</list>
</property>
</bean>
The property lookup is correctly loaded, but do not seems to be used by the registry when running a search query through the API (the "display" property is empty...)
Does anyone has already done that ? I am doing something wrong ?
Regards,
Charles
01-04-2021 10:41 AM
Hi,
Did you manage it to work? I am facing the same problem,
Thanks in advance and best regards!
01-05-2021 10:40 AM
Hi,
I haven't found a solution, so I had to use another technique (sorry, I can't remember how).
It seems that the source code hasn't change since, so I don't think this problem is solved now.
Regards,
Charles
Explore our Alfresco products with the links below. Use labels to filter content by product module.