cancel
Showing results for 
Search instead for 
Did you mean: 

Advanced Search Context (and wild cards) in 4.0a

michaelk
Champ in-the-making
Champ in-the-making
I've noticed some odd (non-intuitive) behavior of the search function in share.

The first issue is the handling of wild cards.  Wildcards '*' and '?' are only recognized if I enclose the search term with quotes. i.e. if I search for book* I do not get any results but if I search for "book*" I do get the results I expect.  Is this by design or is it a bug ?  (This is a Linux installation (if that makes any difference))

The second issue is that if I enter the search in the simple search box, I search the site I'm in, which is what I would expect (i.e. the search is context sensitive). The page displayed as a result gives me the opportunity to change the scope of the search to all sites or all of the repository which is just what one would want.  If, on the other hand, I select the "advanced search" I can only search the entire repository (and it gives me no indication that this is the actual search scope it uses).
Can I (and how would I) customize the advanced search to allow me to specify the search scope (to this site, all sites or all repository) ?  I looked are "share-config.xml" and tries adding the  <repository-search>context</repository-search> to the advanced search, in an attempt to limit the advanced search but this tag only seems to be recognized within the <search> tag. With this limitation the simple search is a lot more useful than the advanced search.  :cry:
2 REPLIES 2

andy
Champ on-the-rise
Champ on-the-rise
Hi

There was a bug with * amd ? generating wildcards queries for the TAG field which does not support this.
This has been fixed.

I have no idea if you can configure the advanced serach page.

You can type any alfresco FTS expression into the search box  …… so you do not have to use the advanced search option to perform an advanced search.

Andy

ldepret
Champ in-the-making
Champ in-the-making
Hi Michael,

In the "\tomcat\webapps\share\components\search\search.js" client-side JavaScript code you'll find the following line:
 
   repo: (searchRepository || this.options.searchQuery.length !== 0).toString(), // always search entire repo with advanced query
If you replace that with:
 
   repo: (searchRepository).toString(), 
You'll get the following behaviour without any further Share UI changes:
“Advanced Search” from the share Dashboard (not in a site) : searches in all sites (adds PATH:"/app:company_home/st:sites/*/*//*" to query)
“Advanced Search” from a page within a site (e.g. test) : searches only in current site (adds PATH:"/app:company_home/st:sites/cm:test/*//*" to query)

The only UI change required then is to replace the result message:
   1 result(s) found in respository
with:
   1 result(s) found
because it could be in site or sites (search will not look in repository).

I've tested this on Alfresco 3.4.0

If you want to specify the search scope (to this site, all sites or all repository) like the simple search you will need some more UI changes and pass the correct parameters in the script (searchAllSites, searchRepository in search.js). Please share the code if you implement this.

The site path is added to the query in the Alfresco backend JavaScript:
"tomcat\webapps\alfresco\WEB-INF\classes\alfresco\templates\webscripts\org\alfresco\slingshot\search\search.lib.js"

  if (ftsQuery.length !== 0)
   {
      // we processed the search terms, so suffix the PATH query
      var path = null;
      if (!params.repo)
      {
         path = SITES_SPACE_QNAME_PATH;
         if (params.siteId !== null && params.siteId.length > 0)
         {
            path += "cm:" + search.ISO9075Encode(params.siteId) + "/";
         }
   …


Luk