cancel
Showing results for 
Search instead for 
Did you mean: 

Making Share use AND in serch by default

loftux
Star Contributor
Star Contributor
I'm trying to change default search in Share to be AND (and not OR), feedback from many users is that this is what they expect (Google like…)
I have modified repo.jscript.Search class so this can be set by parameters, and it takes effect (se debug output below). Problem is that when AND is used there are no results.
search.get.config.xml modified to have <default-query-template>%(TEXT)</default-query-template>, also tried %(ALL).

I have created some test documents with aaaa in them.

This gives 0 result ( using sp.setDefaultOperator(SearchParameters.AND in Search.java);
EXPECTED: 2

Why do I not get any results here?

 2012-08-22 18:20:44,769  DEBUG [repo.jscript.ScriptLogger] [http-8080-60] Query:
((PATH:"/app:company_home/st:sites/*/*//*" AND (aaaa  AND (+TYPE:"cm:content" +TYPE:"cm:folder")) ) AND -TYPE:"cm:thumbnail" AND -TYPE:"cm:failedThumbnail" AND -TYPE:"cm:rating") AND NOT ASPECT:"sys:hidden"
Sortby:
2012-08-22 18:20:44,786  DEBUG [repo.jscript.Search] [http-8080-60] jScript search andOperator true
2012-08-22 18:20:44,786  DEBUG [repo.jscript.Search] [http-8080-60] jScript search: SearchParameters [allAttributes=[], defaultFTSFieldOperator=AND, defaultFTSOperator=AND, defaultFieldName=keywords, excludeDataInTheCurrentTransaction=false, language=fts-alfresco, limit=502, limitBy=FINAL_SIZE, locales=[], maxItems=-1, maxPermissionCheckTimeMillis=-1, maxPermissionChecks=-1, mlAnalaysisMode=null, namespace=http://www.alfresco.org/model/content/1.0, permissionEvaluation=EAGER, query=((PATH:"/app:company_home/st:sites/*/*//*" AND (aaaa  AND (+TYPE:"cm:content" +TYPE:"cm:folder")) ) AND -TYPE:"cm:thumbnail" AND -TYPE:"cm:failedThumbnail" AND -TYPE:"cm:rating") AND NOT ASPECT:"sys:hidden", queryParameterDefinitions=[], queryTemplates={keywords=%(TEXT)}, skipCount=0, sortDefinitions=[], stores=[workspace://SpacesStore], textAttributes=[], fieldFacets=[]]
2012-08-22 18:20:44,842  DEBUG [repo.jscript.ScriptLogger] [http-8080-60] Processing resultset of length: 0
2012-08-22 18:20:44,842  DEBUG [repo.jscript.ScriptLogger] [http-8080-60] Filtered resultset to length: 0. Discarded item count: 0

This gives 2 result ( using sp.setDefaultOperator(SearchParameters.OR in Search.java);
EXPECTED: 2

2012-08-22 18:23:29,605  DEBUG [repo.jscript.ScriptLogger] [http-8080-25] Query:
((PATH:"/app:company_home/st:sites/*/*//*" AND (aaaa  AND (+TYPE:"cm:content" +TYPE:"cm:folder")) ) AND -TYPE:"cm:thumbnail" AND -TYPE:"cm:failedThumbnail" AND -TYPE:"cm:rating") AND NOT ASPECT:"sys:hidden"
Sortby:
2012-08-22 18:23:29,606  DEBUG [repo.jscript.Search] [http-8080-25] jScript search andOperator false
2012-08-22 18:23:29,607  DEBUG [repo.jscript.Search] [http-8080-25] jScript search: SearchParameters [allAttributes=[], defaultFTSFieldOperator=OR, defaultFTSOperator=OR, defaultFieldName=keywords, excludeDataInTheCurrentTransaction=false, language=fts-alfresco, limit=502, limitBy=FINAL_SIZE, locales=[], maxItems=-1, maxPermissionCheckTimeMillis=-1, maxPermissionChecks=-1, mlAnalaysisMode=null, namespace=http://www.alfresco.org/model/content/1.0, permissionEvaluation=EAGER, query=((PATH:"/app:company_home/st:sites/*/*//*" AND (aaaa  AND (+TYPE:"cm:content" +TYPE:"cm:folder")) ) AND -TYPE:"cm:thumbnail" AND -TYPE:"cm:failedThumbnail" AND -TYPE:"cm:rating") AND NOT ASPECT:"sys:hidden", queryParameterDefinitions=[], queryTemplates={keywords=%(TEXT)}, skipCount=0, sortDefinitions=[], stores=[workspace://SpacesStore], textAttributes=[], fieldFacets=[]]
2012-08-22 18:23:29,636  DEBUG [repo.jscript.ScriptLogger] [http-8080-25] Processing resultset of length: 2
2012-08-22 18:23:29,665  DEBUG [repo.jscript.ScriptLogger] [http-8080-25] Filtered resultset to length: 2. Discarded item count: 0

I have tried the search in many combinations, 1 or more parameters. If I search on node browser with for example ALL:aaaa AND ALL:bbbb I get hits.
Is it that the query template thingy is not compatible with AND?
2 REPLIES 2

loftux
Star Contributor
Star Contributor
Figured it out what was wrong, in search.lib.js for the slingshot Search webscript, you have to add an explicit OR between allowable types. Else it will by ANDed an no nodes will ever be of both types.
ftsQuery += ' AND (+TYPE:"cm:content" OR +TYPE:"cm:folder")';

loftux
Star Contributor
Star Contributor
If anyone is interested i blogged about my changes here
http://loftux.com/2012/08/24/fix-alfresco-share-quick-search/
and in this issue I have attached a source diff https://issues.alfresco.com/jira/browse/ALF-6349