Text.escapeIllegalXpathSearchChars doesn't work correct - Full text search 
failed
---------------------------------------------------------------------------------

                 Key: JCR-2416
                 URL: https://issues.apache.org/jira/browse/JCR-2416
             Project: Jackrabbit Content Repository
          Issue Type: Bug
          Components: jackrabbit-jcr-commons
    Affects Versions: 1.6.0
         Environment: Don't matter
            Reporter: Oleg Varaksin
            Priority: Minor


Hello,

I use instructions from http://wiki.apache.org/jackrabbit/EncodingAndEscaping 
to escape values in queries for full text search, but the method 
Text.escapeIllegalXpathSearchChars does something strange replacements. If I 
want to search a whole phrase I surround the text with double quotes. This is 
described in JCR 170 (section 6.6.5.2 jcr:contains Function) A term may be 
either a single word or a phrase delimited by double quotes ("). Well. I write 
now a String "\"Have much fun\"", pass it through 
Text.escapeIllegalXpathSearchChars and let execute then query. An exception is 
thrown:

javax.jcr.RepositoryException: Exception building query: 
org.apache.lucene.queryParser.ParseException: Cannot parse '"Have much fun\"': 
Lexical error at line 1, column 17.  Encountered: <EOF> after : "\"Have much 
fun\\\""

I think, Text.escapeIllegalXpathSearchChars doesn't work correct if the whole 
phrase is surrounded by \" (double quotes within String) and the sign \" is the 
last sign.

Query statement: //element(*, cssns:file)[jcr:contains(jcr:content, '"Have much 
fun"')]
Executing: QueryManager.createQuery(statement, Query.XPATH).execute();

I use as dependency Apache Lucene Core 2.4.1. As workaround I call now simple 
userValue.replaceAll("'", "''"); instead of 
Text.escapeIllegalXpathSearchChars(userValue).replaceAll("'", "''") and it 
works fine!

Best regards.
Oleg.


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to