cancel
Showing results for 
Search instead for 
Did you mean: 

Create a custom property property lookup for REST API Search

amoae
Champ on-the-rise
Champ on-the-rise

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

2 REPLIES 2

ceeliro
Champ in-the-making
Champ in-the-making

Hi,

Did you manage it to work? I am facing the same problem,

Thanks in advance and best regards!

amoae
Champ on-the-rise
Champ on-the-rise

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