You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Ahmed Elshereay <AE...@idc.com> on 2010/07/12 16:47:04 UTC

Full Text Search jackrabbit 2.1.0

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.

Re: Full Text Search jackrabbit 2.1.0

Posted by Alexander Klimetschek <ak...@day.com>.
On Mon, Jul 12, 2010 at 17:24, Ahmed Elshereay <AE...@idc.com> wrote:
> 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?

Please see the correct query I provided. The full text index from
binary files is not on the "jcr:data" property, but on the nt:file (or
nt:resource) node scope.

Regards,
Alex

-- 
Alexander Klimetschek
alexander.klimetschek@day.com

Re: Full Text Search jackrabbit 2.1.0

Posted by Ahmed Elshereay <AE...@idc.com>.
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 <ak...@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 <AE...@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


Re: Full Text Search jackrabbit 2.1.0

Posted by Alexander Klimetschek <ak...@day.com>.
On Mon, Jul 12, 2010 at 16:47, Ahmed Elshereay <AE...@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