11-02-2016 08:23 AM
Hi,
I'm looking for a way to search by custom field in my custom aspect. I found some information, like https://www.bluefishgroup.com/insights/ecm/adding-metadata-fields-to-simple-search-and-live-search-w... or How to search metadata of documents ,but it seems very complicated. I can't find XML files, which are mentioned in these documents:
For example in first document from BlueFishGroup, there is information, that files
- live-search-docs.get.config.xml
- search.get.config.xml
should be extracted from file tomcat/webapps/alfresco/WEB-INF/lib/alfresco-remote-api-5.0.2.1.jar, from directory alfresco/templates/webscripts/org/alfresco/slingshot/search/, but I don't have that directory in this JAR file (in alfresco/templates/webscripts/org/alfresco/slingshot/ there are only directories called calendar and quadds, there is no search). Also even if I somehow would find this file, it is written, that
These files can now be modified to add additional metadata fields as needed. Once the files have been updated, they should be deployed to the ‘extensions’ directory so that they will override the out of the box configuration. If you are deploying your code as a custom AMP file, the files should target the following directory:
- tomcat/webapps/alfresco/WEB-INF/classes/alfresco/extension/templates/webscripts/org/alfresco/slingshot/search
I don't want to deploy it as a custom AMP, so I assume I should copy them to 'extension' directory. But where is that? Should i put them to those JAR file? Or should it be tomcat/webapps/alfresco/WEB-INF/classes/alfresco/extension directory? Or maybe /tomcat/shared/classes/alfresco/extension/ ?
I'm looking for help in that matter, because I'm begginer in Alfresco, and I just don't have enough knowledge to do that.
In second document, there is information, that if I want to search by custom metadata, I should write a webscript, and it is way over my knowledge.
Maybe there are some other ways to do that? I just can't believe, that managing so basic procedure, as searching by metadata is so complicated to insert.
11-10-2016 04:29 AM
Hi
I don't know whether you created custom aspect properly. If you want to create custom aspect, you need to create model file and register it through context file.You can place these files in tomcat/shared/classes/alfresco/extension. In extension folder you may find "exampleModel.xml.sample", make a copy of that file in same folder(extension) and remove its .sample extension and make .xml file. After that, edit imports if you want to inherit some aspect defined in other content model this comes under <imports> tag. If you don't want inheritance , keep it as it is. Under <namespaces> tag create your namespace by giving unique URI and prefix. Remove the <types> element. And edit the <aspects> element and define your custom aspect there by giving it's name and add your custom properties in <properties> element. Also in order to make your property indexed add index tag and define its enabled attribute to "true" as code snippet given below:
<index enabled="true">
<tokenised>TRUE</tokenised>
<facetable>false</facetable>
</index>
At this stage you created custom model which contains your aspect. In order to make alfresco to know your model register it with spring bean from a context file. You can also get sample context file example-model-context.xml, copy it and change its extension as you did before and in that file edit <beans> element and change bean id. And also change the path of the model file to the model file created by you.
After restart of alfresco service this model will be created and you can apply your aspect to any content in repository and can also search its properties through REST API or CMIS or alfresco share.
Here I am assuming you are using share. In order to make your aspect visible to share, edit share-config-custom.xml file present in tomcat/shared/classes/alfresco/web-extension(create if it is not present). Add aspect created by you to <visible> element. And you can edit or create advanced search forms through by placing this code in the same file.
Refer this code if you want to register your own advanced search form
<config replace='true' evaluator='string-compare' condition='AdvancedSearch'>
<advanced-search>
<forms>
<form labelId='search.form.label.cm_content' descriptionId='search.form.desc.cm_content'>cm:content</form>
<form labelId='search.form.label.cm_folder' descriptionId='search.form.desc.cm_folder'>cm:folder</form>
</forms>
</advanced-search>
</config>
And Refer this code to create or edit form
<config evaluator='model-type' condition='cm:folder'>
<forms>
<form id='doclib-common'>
<field-visibility>
<show id='cm:name' />
<show id='cm:title' force='true' />
<show id='cm:description' force='true' />
</field-visibility>
<create-form template='../documentlibrary/forms/doclib-common.ftl' />
<appearance>
<field id='cm:title'>
<control template='/org/alfresco/components/form/controls/textfield.ftl' />
</field>
</appearance>
</form>
<form id='search'>
<field-visibility>
<show id='cm:name' />
<show id='cm:title' force='true' />
<show id='cm:description' force='true' />
</field-visibility>
</form>
</forms>
</config>
For further details you can go through this link
Apart from share, if you are using CMIS then you can search your properties through query. Or you can also search it by REST APIs provided by alfresco.
Thanks,
Kalpesh
11-02-2016 10:02 AM
Hi,
First could you tell us what version of Alfresco do you use ? It will help to look into the right code base.
For example in the latest version of Alfresco, the files are located in the share-services :
share/live-search-docs.get.config.xml at master · Alfresco/share · GitHub
And
share/search.get.config.xml at master · Alfresco/share · GitHub
If you can't find it in alfresco-remote-api jar look for a jar called share-services.
Regards
11-02-2016 12:21 PM
Both live-search-docs.get.config.xml and search.get.config.xml are packaged in
alfresco-share-services-***.jar under path alfresco/templates/webscripts/org/alfresco/slingshot/search
Yes you can place it at tomcat/webapps/alfresco/WEB-INF/classes/alfresco/extension/templates/webscripts/org/alfresco/slingshot/search
but it is recommeded to place it at /tomcat/shared/classes/alfresco/extension/templates/webscripts/org/alfresco/slingshot/search (make sure /tomcat/shared/classes is configured in your classpah).
11-03-2016 08:50 AM
I don't have neither of this directories....
instead of
tomcat/webapps/alfresco/WEB-INF/classes/alfresco/extension/templates/webscripts/org/alfresco/slingshot/search
I have
/home/alfresco/alfresco-community/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/templates/webscripts/org/alfresco/slingshot/rmsearch
- this one is most similar
and instead of
/tomcat/shared/classes/alfresco/extension/templates/webscripts/org/alfresco/slingshot/search
I have
/home/alfresco/alfresco-community/tomcat/shared/classes/alfresco/extension
- and thats it, no templates directory.
Maybe I should made them? But I assume, that if they not exist, Alfresco would not reach to them. Where can I find place to put files?
11-03-2016 09:08 AM
If the folder dose not exist ,please just create it ,it will work. Alfresco will search the folder.
11-03-2016 09:42 AM
Thank you, I 'll try that.
But where should I copy files :
- exampleModel.xml.sample
- example-model-context.xml.sample
after editing them, and removing .sample suffix ? To the same directory as search XMLs? Or leave it with other samle files in /home/alfresco/alfresco-community/tomcat/shared/classes/alfresco/extension directory?
11-03-2016 10:04 AM
exampleModel.xml.sample/example-model-context.xml.sample are located in /home/alfresco/alfresco-community/tomcat//webapps/alfresco/WEB-INF/lib/alfresco-repository-**.jar under path /alfrescoextension
Copy them in to /home/alfresco/alfresco-community/tomcat/shared/classes/alfresco/extension and rename them to exampleModel.xml//example-model-context.xml.
03-21-2017 12:02 PM
Hi Kayne, Tomasz,
Sorry, newbie here. I followed your thread up until creating nonexistent path;
Custom properties are still not searchable. What did I miss? Please help
Regards,
ChrisTogz
10-13-2018 08:59 PM
Hello,
I am working alfresco enterprise edition v5.2 I couldn't find alfresco-share-services-***.jar anywhere. Please help on this.
I have to search content based two custom attributes (one property from document and another user role)
10-16-2018 10:43 AM
Why do you want the jar?
You don't need it at all to configure search.
It would be better if you start a new discussion and explaining what you are trying to do, what you have already tried, and what is not working.
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.