1

Unfortunately we have a special folder named "_archive" in our repository everywhere. This folder has its purpose. But: When searching for content/documents we want to exclude it and every content beneath "_archive".

So, what i want is to exclude the path and its member from all user searches. Syntax is easy with fts:

your_query AND -PATH:"//cm:_archive//*"

to test: https://www.docdroid.net/RmKj9gB/search-test.pdf.html take the pdf, put it into your repo twice:

  • /some_random_path/search-test.pdf
  • /some_random_path/_archive/search-test.pdf

In node-browser everything works as expected:

TEXT:"HODOR" AND -PATH:"//cm:_archive//*"
= 1 result

TEXT:"HODOR"
= 2 results

So, my idea was to edit search.get.config.xml and add the exclusion to the list of properties:

<search>
    <default-operator>AND</default-operator>
    <default-query-template>%(cm:name cm:title cm:description ia:whatEvent
        ia:descriptionEvent lnk:title lnk:description TEXT TAG) AND -PATH:"//cm:_archive//*"
    </default-query-template>
</search>

But it does not work as intended! As soon as i am using 'text:' or 'name:' in the search field, the exclusion seems to be ignored.

What other option do i have? Basically just want to add the exclusion to the base query after the default query template is used.

Version is Alfresco Community 5.0.d

thanks!

user1429166
  • 132
  • 12
  • I've always had performance issues when using PATH queries, you don't? How big is your repo, circa? – Lista May 26 '16 at 15:20
  • the wiki says search can get slow and you might want to increase cache size. but i had no problem with it yet. I run this in a dev environment with 5gb of content – user1429166 May 27 '16 at 07:47

1 Answers1

3

I guess you're mistaken what query templates are meant for. Take a look at the Wiki.

So what you're basically doing is programmatically saying I've got a keyword and I want to match the keywords to the following metadata fields.

Default it will match cm:name cm:title cm:description etc. This can be changed to a custom field or in other cases to ALL.

So putting an extra AND or here of whatever won't work, cause this isn't the actual query which will be built. I can go on more about the query templates, but that won't do you any good.

In your case you'll need to modify the search.get webscript of Alfresco and the method called function getSearchResults(params) in search.lib.js (which get's imported).

Somewhere in at the end of the method it will do the following:

ftsQuery = '(' + ftsQuery + ') AND -TYPE:"cm:thumbnail" AND -TYPE:"cm:failedThumbnail" AND -TYPE:"cm:rating" AND -TYPE:"st:site"' + ' AND -ASPECT:"st:siteContainer" AND -ASPECT:"sys:hidden" AND -cm:creator:system AND -QNAME:comment\\-*';

Just add your path to query to it and that will do.

Tahir Malik
  • 6,623
  • 15
  • 22
  • 1
    I am using 5.0.d community - I don't have the mentioned method in search.get.js – user1429166 May 26 '16 at 13:36
  • The method is in search.lib.js, the search.get.js does an import. – Tahir Malik May 26 '16 at 15:40
  • What version are you working on? Are you sure this is working for 5.0.d? – user1429166 May 27 '16 at 07:54
  • It appears that in 5.0.d the line looks a bit different. `ftsQuery = '(' + ftsQuery + ') AND -TYPE:"cm:thumbnail" AND -TYPE:"cm:failedThumbnail" AND -TYPE:"cm:rating" AND -TYPE:"st:site"' + ' AND -ASPECT:"st:siteContainer" AND -ASPECT:"sys:hidden" AND -cm:creator:system AND -QNAME:comment\\-*';` – Axel Faust May 27 '16 at 09:33
  • Pff @user1429166 are you really going there? Use total commander or something else and find the search.lib.js in the jar file. Do we really need to do your work for you..... In this case the file is located in alfresco-remote-api-5.0.d.jar – Tahir Malik May 27 '16 at 09:36
  • @AxelFaust my bad, I've copied it probably from a different Alfresco version. – Tahir Malik May 27 '16 at 09:37