简体   繁体   English

从所有用户搜索中排除某个路径

[英]exclude a certain path from all user searches

Unfortunately we have a special folder named "_archive" in our repository everywhere. 不幸的是,我们的存储库中到处都有一个名为“_archive”的特殊文件夹。 This folder has its purpose. 这个文件夹有它的目的。 But: When searching for content/documents we want to exclude it and every content beneath "_archive" . 但是:在搜索内容/文档时,我们希望将其排除在“_archive”之下。

So, what i want is to exclude the path and its member from all user searches. 所以,我想要的是从所有用户搜索中排除路径及其成员。 Syntax is easy with fts: 使用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: 测试: https//www.docdroid.net/RmKj9gB/search-test.pdf.html获取pdf,将其放入您的回购两次:

  • /some_random_path/search-test.pdf /some_random_path/search-test.pdf
  • /some_random_path/_archive/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.get.config.xml并将排除添加到属性列表中:

<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. 只要我在搜索字段中使用“text:”或“name:”,就会忽略排除。

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 版本是Alfresco Community 5.0.d

thanks! 谢谢!

I guess you're mistaken what query templates are meant for. 我想你错了什么查询模板的意思。 Take a look at the Wiki . 看看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 . 默认它将匹配cm:name cm:title cm:description等。这可以更改为自定义字段,或者在其他情况下更改为ALL

So putting an extra AND or here of whatever won't work, cause this isn't the actual query which will be built. 因此,添加一个额外的AND或此处的任何不起作用,导致这不是将要构建的实际查询。 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). 在您的情况下,您需要修改Alfresco的search.get webscript和search.lib.js中的函数getSearchResults(params)的方法(获取导入)。

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. 只需添加您的查询路径,即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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