Bug 780250 (SOA-2647)

Summary: modeshape full-text search
Product: [JBoss] JBoss Enterprise SOA Platform 5 Reporter: Aleksandar Kostadinov <akostadinov>
Component: EDSAssignee: Van Halbert <vhalbert>
Status: CLOSED NOTABUG QA Contact:
Severity: high Docs Contact:
Priority: high    
Version: 5.1.0.ER4CC: rhauch
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
URL: http://jira.jboss.org/jira/browse/SOA-2647
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2010-12-07 20:50:43 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Aleksandar Kostadinov 2010-12-07 09:24:22 UTC
project_key: SOA

      String ftsExpression = "myfile*";
      Query ftsQuery = qm.createQuery(ftsExpression, Query.JCR_SQL2);

This results in javax.jcr.query.InvalidQueryException: The JCR-SQL2 query "myfile*" is not well-formed: Unexpected token 'myfile' at line 1, column 1

I have also tried single/double quoting the word, multiple words, the 'contains(...,...)' syntax but everything results in an InvalidQueryException.

Am I doing anything wrong?

Comment 1 Randall Hauch 2010-12-07 15:50:17 UTC
If you're trying to use the full-text search language, you need to pass the "Search" value (or the JcrRepository.QueryLanguage.SEARCH constant, if you have access to that package on your classpath) as the second parameter to "createQuery".

As you've coded it, you're actually asking ModeShape to treat your query expression as JCR-SQL2. If you'd like to use JCR-SQL2, the equivalent query is:

    SELECT [jcr:primaryType] FROM [nt:base] WHERE CONTAINS( [nt:base].*, "myfile*" )

Comment 2 Randall Hauch 2010-12-07 15:53:01 UTC
In other words, if you want to use the full-text search language, your code should either be:

      String ftsExpression = "myfile*"; 
      Query ftsQuery = qm.createQuery(ftsExpression, JcrRepository.QueryLanguage.SEARCH);

or

      String ftsExpression = "myfile*"; 
      Query ftsQuery = qm.createQuery(ftsExpression, "Search");

or, if you do want to use JCR-SQL2, it should be this:

      String ftsExpression = "SELECT [jcr:primaryType] FROM [nt:base] WHERE CONTAINS( [nt:base].*, 'myfile*' )"; 
      Query ftsQuery = qm.createQuery(ftsExpression, Query.JCR_SQL2);

Comment 3 Van Halbert 2010-12-07 16:03:29 UTC
Comment was provided as to how querying should be performed.

Comment 4 Aleksandar Kostadinov 2010-12-07 20:50:43 UTC
Thanks, that JCR 2 way works.