cancel
Showing results for 
Search instead for 
Did you mean: 

Alfresco Share Search

petar
Champ in-the-making
Champ in-the-making
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.
5 REPLIES 5

jpotts
World-Class Innovator
World-Class Innovator
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. Smiley Happy

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

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.

petar
Champ in-the-making
Champ in-the-making
Thanks Jeff,

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

mccarthymp
Confirmed Champ
Confirmed Champ
Hi Petar,

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.

bremmington
Champ on-the-rise
Champ on-the-rise
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:


    /**
     * 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;
    }