cancel
Showing results for 
Search instead for 
Did you mean: 

Categories on Advanced Search query

adrianfp84
Champ in-the-making
Champ in-the-making
Hi everybody,

I've modified the advanced search form to let users search documents by tags and Categories. That modification works fine but I noticed that Categorie's control works with OR instead of AND.
For example, if you select one or more categories you will get documents with any of these categories, not with all of these.

I think in some scenarios that's ok but when you are working with a lot of documents (is my case) search for documents with all of that categories is the better option.

So, is there any way to change the Advanced Search behavior to be able to find documents with ALL the specified categories?


For more info, to customize the Adv. Search form I followed this link :
    <a href="https://wiki.alfresco.com/wiki/Share_Advanced_Search#Categories_Property">https://wiki.alfresco.com/wiki/Share_Advanced_Search#Categories_Property</a>


Thanks in advance!
7 REPLIES 7

afaust
Legendary Innovator
Legendary Innovator
Hello,

the search by categories works the same as the search by multiple terms in other fields - they use the default operator (OR) during evaluation.
There are addons in the Alfresco community that enable you to change that, e.g. <a href="https://addons.alfresco.com/addons/alfresco-search-tweaks-zylk">Search Tweaks by Zylk</a> or <a href="https://addons.alfresco.com/addons/alfresco-share-and-search">Share AND Search</a>.

Regards
Axel

adrianfp84
Champ in-the-making
Champ in-the-making
Hi,

I tried the extension from Contezza.nl and it doesn't solve the problem. The Zylk's extension doesn't appear on their website.

I continued investigating on the issue in the following way:

    1. Adding the "mode" parameter on the cm:content Search Form in share-form-config.xml (<a href="https://wiki.alfresco.com/wiki/Forms#category.ftl">Forms- AlfrescoWiki</a>)
    2. I checked the rendered Advanced Search form and the mode is OK, there is a "AND":

<strong><input id="page_x002e_search_x002e_advsearch_x0023_default_0_prop_cm_categories-mode" name="prop_cm_categories-mode" value="AND" type="hidden"></strong>

    3. The searching request has the right mode parameter:

http://localhost:8080/share/page/site/otv/search?t=&q={
"prop_cm_name":"",
"prop_cm_title":"",
"prop_cm_description":"",
"prop_cm_taggable":"",
"prop_cm_categories":"workspace://SpacesStore/1ef91b62-73ae-4450-9552-a76410530c87,workspace://SpacesStore/3cd6322a-f6e1-4559-bc3a-9f26b09d9e45",
"prop_cm_categories-mode":"AND",
"prop_mimetype":"",
"prop_cm_modified-date-range":"",
"prop_cm_modifier":"","datatype":"cm:content"
}&r=true

I don't know if I'm doing something wrong but it seems to be ok. May be there is a bug in the Alfresco's ORM generating the query.

Is it possible?

I forgot to tell that I'm using 5.0.a version


Thanks!

afaust
Legendary Innovator
Legendary Innovator
Hello,

there is no ORM involved as this query is executed on the SOLR / Lucene search index - not on the database. The parameters submitted to the search look fine to me, but the search data web script (search.lib.js on Repository-tier) does not evaluate the -mode parameter for cm:categories (it does for any other type of field). I believe the particular documentation in the (publicly editable) wiki is either outdated, was never correct in the first place or that bug has been in the product for quite a while.
Please file a JIRA ticket (if there is not already one) for this.

Regards
Axel

adrianfp84
Champ in-the-making
Champ in-the-making
I created a bug ticket because there was not any ticket reporting this issue.

I hope they fix it soon because is an important requirement for our most important customer.

This is the <a href="https://issues.alfresco.com/jira/browse/ALF-21111?filter=-2">JIRA ticket</a>

Thank you Axel!

cesarista
World-Class Innovator
World-Class Innovator
Hi Adrian and Axel:

Search Tweaks by Zylk is a component for implementing AND operator (instead of OR) in simple search (and it was developed for Alfresco 4.x). So the question it is quite different from this.

Regarding Adrian's case I had several issues (case 00161039) on the past relating 4.1.x EE with tags and categories operators. Adrian, did you try in share-config-custom.xml ?


<control-param name="mode">AND</control-param>


Regards.

–C.

cesarista
World-Class Innovator
World-Class Innovator
Agree with Axel, the problem is in the construction of the query, what it is passed to SOLR /Lucene subsystem and it does not involve database.

–C.

adrianfp84
Champ in-the-making
Champ in-the-making
I added the categories field for cm:content on the default cm:content search form on share-form-config.xml.

I know that isn't the best practice so I tried extending that form on share-config-custom.xml but it doesn't take effect.


Thanks Cesar!