On Mon, Jul 12, 2010 at 16:47, Ahmed Elshereay <[email protected]> wrote: > Hi everyone, > > I use jackrabbit 2.1.0, and I'd like to do full text search in nodes that > hold documents (word, pdf.. and so on) > I wrote the following code, and the porblem is that it never returns > result! Although the documents are there and the query string which I > enter does exist in those documents. Don't know what did I miss or did > wrong! > Could it be because I didn't specify values for the columns and orderings? > Actually I don't know what are these! > When I use XPath (which is deprecated) it works fine. > > Here is the JQOM code: > > QueryManager queryManager = > session.getWorkspace().getQueryManager(); > QueryObjectModelFactory qomf = queryManager.getQOMFactory(); > ValueFactory vf = session.getValueFactory(); > > String selectorName = "fullTextSearchSelector"; > Selector selector = qomf.selector("nt:resource", selectorName); > > Constraint constraint = qomf.fullTextSearch(selectorName, > "jcr:data", qomf.literal(vf > .createValue("someText"))); > > QueryObjectModel queryObjectModel = qomf.createQuery(selector, > constraint, null, > null); > > QueryResult result = queryObjectModel.execute(); > RowIterator iter = result.getRows(); > System.out.println("size: " + iter.getSize()); > while (iter.hasNext()) { > Row row = iter.nextRow(); > System.out.println("Row: " + row.toString()); > } > > > Please, can any one tell me what could be wrong here? And if it's better > ot use SQL, so how? > > Thank you in advance.
There is a FullTextSearch constraint in JQM [1]. The query (in JCR-SQL2) would be: SELECT * FROM [nt:file] WHERE CONTAINS(., 'someText') Full text content should be aggregated on the nt:file level by default and the '.' denotes that node scoped full text index. Should be almost identical to a JCR 1.0 SQL full text search. And you can still continue to use xpath or sql from JCR 1.0, Jackrabbit will continue to support them. [1] http://www.day.com/specs/jcr/2.0/6_Query.html#FullTextSearch Regards, Alex -- Alexander Klimetschek [email protected]
