简体   繁体   中英

exclude a certain path from all user searches

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!

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM