cancel
Showing results for 
Search instead for 
Did you mean: 

Help: Want AND search behavior in category search in advanced search

yuva0103
Champ in-the-making
Champ in-the-making
Hi,

Added category in advance search form for content, but when selecting multiple categories, it works like OR behavior. I want to search like AND, Is there any configuration to do this.

Please help, I'm new to alfresco. TIA
4 REPLIES 4

afaust
Legendary Innovator
Legendary Innovator
Hello,

yes, there is configuration for it, which unfortunately was not documented until just now. See <a href="https://wiki.alfresco.com/wiki/Forms#category.ftl">the Forms wiki page</a> for details on the <b>mode</b> parameter.

Regards
Axel

yuva0103
Champ in-the-making
Champ in-the-making
Its not working Smiley Sad Still working like default <b>OR</b> behavior.

here is the change I made in share-form-config.xml for category

<blockcode>
                <field id="cm:categories">
                  <control template="/org/alfresco/components/form/controls/category.ftl">
                    <control-param name="compactMode">true</control-param>
          <control-param name="mode">and</control-param>
          <control-param name="showSubCategoriesOption">true</control-param>
                  </control>
               </field>
</blockcode>

Please let me know if I missing anything.

yuva0103
Champ in-the-making
Champ in-the-making
I'm not sure this is best solution or not, I solved this requirement by a small change in search.lib.js file in path alfresco\WEB-INF\classes\alfresco\templates\webscripts\org\alfresco\slingshot\search.

In  method getSearchResults(params) change this line.  'OR' to 'AND'

<blockcode>
      catQuery += (firstCat ? '' : ' AND ') + "PATH:\"" + catNode.qnamePath + (useSubCats ? "//*\"" : "/member\"" );
</blockcode>

ipirat
Champ in-the-making
Champ in-the-making
Hi,

having not much background in Alfresco, but a lot of background in search, here my suggestion:

<ul>
<li>if the user selects several categories within the same category, they should be connected with OR (e.g. user selects languages/English and languages/German => they most probably want documents taht are German or English, not documents which are English and German at the same time)
<li>if the user selects several categories contained in different categories, they should be connected with AND (e.g. user selects langages/English and region/EMEA => they most probably want documents in English language from EMEA, not all English documents from any region plus all documents from EMEA in any language)
</ul>

(assuming a 'properly built' category tree – where the subcategories are actually subcategories)