jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ahmed Elshereay <AElsher...@idc.com>
Subject Re: Full Text Search jackrabbit 2.1.0
Date Mon, 12 Jul 2010 15:24:23 GMT
Hi Alexander,

Thanks a lot for your reply. I still don't understand why my code doesn't 
return results, while XPath does!
What's wrong or missing with ti?





Alexander Klimetschek <aklimets@day.com> 
07/12/2010 05:17 PM
Please respond to
users@jackrabbit.apache.org


To
users@jackrabbit.apache.org
cc

Subject
Re: Full Text Search jackrabbit 2.1.0






On Mon, Jul 12, 2010 at 16:47, Ahmed Elshereay <AElshereay@idc.com> 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
alexander.klimetschek@day.com


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message