Alfresco Share Search
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2011 08:03 AM
I use Alfresco 3.4d and in Alfresco Web Quick Start i have web asset with tag Q&Q. When use search by tags results are nothing.
Riding something about Alfresco search and find something about Apache Lucene ignore special characters + - && || ! ( ) { } [ ] ^ " ~ * ? : \
How i can solve this problem? I try with \& but still nothing.
Riding something about Alfresco search and find something about Apache Lucene ignore special characters + - && || ! ( ) { } [ ] ^ " ~ * ? : \
How i can solve this problem? I try with \& but still nothing.
Labels:
- Labels:
-
Archive
5 REPLIES 5
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2011 07:33 PM
Using 3.4d Community, I'm noticing that in Share and Explorer the tags widget won't allow the ampersand. That doesn't bode well for you. 
I set the title field to "gin&tonic" and then did some searches in the node browser using the Lucene syntax. All of the following found the doc:
@cm\:title:"gin*"
@cm\:title:"gin&tonic"
@cm\:title:"*tonic"
@cm\:title:"gin?tonic"
@cm\:title:"gin&t?nic"
So then I set the title to "Q&Q" (your example) and did similar tests, with success.
That tells me it is possible to find an object with a property that contains no spaces and an ampersand. Maybe this is specific to tags? You might have to fire up the debugger to find out.
Jeff

I set the title field to "gin&tonic" and then did some searches in the node browser using the Lucene syntax. All of the following found the doc:
@cm\:title:"gin*"
@cm\:title:"gin&tonic"
@cm\:title:"*tonic"
@cm\:title:"gin?tonic"
@cm\:title:"gin&t?nic"
So then I set the title to "Q&Q" (your example) and did similar tests, with success.
That tells me it is possible to find an object with a property that contains no spaces and an ampersand. Maybe this is specific to tags? You might have to fire up the debugger to find out.
Jeff
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2017 04:24 AM
Is ampersand is working for searching in alfresco 5.2 ?
like if I want to search a file with "&".
I am not able to search with this.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2011 02:34 AM
Thanks Jeff,
But I am using search from WCMQS client api. Here is my implementation
Maybe client api make some postprocesing for input term and replace & with something else?
Your example is clear Lucine search and that is okej.
Regards Petar
But I am using search from WCMQS client api. Here is my implementation
web.getSectionByPath("/doc/").searchByTag(term, 10, 0).getResults();
Maybe client api make some postprocesing for input term and replace & with something else?
Your example is clear Lucine search and that is okej.
Regards Petar

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2011 02:05 PM
Hi Petar,
In WQS the query term is run through a "query sanitizer". Here is the code:
This is in org.alfresco.wcm.client.util.QuerySanitizer in the WQS Client API project.
As you can see it replaces the '&' with a ' ' (space) character. I'm not sure if you would run into problems by modifying this code or not.
In WQS the query term is run through a "query sanitizer". Here is the code:
/** * Overridable sanitization method * @param text * @return */ protected String sanitizeImpl(String text) { return text == null ? null : text.replaceAll("[\"'%?*()$^<>/{}\\[\\]#~@.,|\\\\+!:;&`¬=]", " "); }
This is in org.alfresco.wcm.client.util.QuerySanitizer in the WQS Client API project.
As you can see it replaces the '&' with a ' ' (space) character. I'm not sure if you would run into problems by modifying this code or not.

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2011 07:38 AM
Hello
Yes, Michael has correctly identified the class that needs customising for your case. The QuerySanitizer is specifically designed to allow overriding. Hopefully the javadoc gives sufficient info about how to do it, but let me know if you need further information:
Yes, Michael has correctly identified the class that needs customising for your case. The QuerySanitizer is specifically designed to allow overriding. Hopefully the javadoc gives sufficient info about how to do it, but let me know if you need further information:
/** * Overridable sanitization method * @param text * @return */ protected String sanitizeImpl(String text) { return text == null ? null : text.replaceAll("[\"'%?*()$^<>/{}\\[\\]#~@.,|\\\\+!:;&`¬=]", " "); } /** * Inject a new implementation if desired. Create a subclass of this class, override the sanitizeImpl operation, * and inject an instance of it using this operation. QuerySanitizer.sanitize will then be routed to your object. * @param sanitizer */ public static void setSanitizer(QuerySanitizer sanitizer) { instance = sanitizer; }
