You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-issues@jackrabbit.apache.org by "Davide Giannella (JIRA)" <ji...@apache.org> on 2017/07/05 13:59:00 UTC

[jira] [Commented] (OAK-6418) CONTAINS SQL2 parameter does not work

    [ https://issues.apache.org/jira/browse/OAK-6418?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16074800#comment-16074800 ] 

Davide Giannella commented on OAK-6418:
---------------------------------------

please have a look at https://jackrabbit.apache.org/oak/docs/query/query-engine.html and https://jackrabbit.apache.org/oak/docs/query/query-troubleshooting.html.

Also ensure you have a fulltext index indexing the property and you will have to wait some time as normally full-text indexes are async.

> CONTAINS SQL2 parameter does not work
> -------------------------------------
>
>                 Key: OAK-6418
>                 URL: https://issues.apache.org/jira/browse/OAK-6418
>             Project: Jackrabbit Oak
>          Issue Type: Bug
>          Components: jcr
>    Affects Versions: 1.6.1
>            Reporter: Marco Piovesana
>
> Query result is wrong when using the "CONTAINS" operator. See the following test example:
> {code:borderStyle=solid}
>     @Test
>     public void shouldFindOneElement() throws Exception {
>         File driveFile = new File("/tmp/oakTest", "oakrepo");
>         File repositoryFile = new File(driveFile, "repository");
>         File dataStoreFile = new File(driveFile, "datastore");
>         BlobStore blobStore = new FileBlobStore(dataStoreFile.getAbsolutePath());
>         FileStore fileStore = FileStoreBuilder.fileStoreBuilder(repositoryFile).withBlobStore(blobStore).build();
>         SegmentNodeStore segmentNodeStore = SegmentNodeStoreBuilders.builder(fileStore).build();
>         Jcr jcr = new Jcr(segmentNodeStore).with(new InitialContent()).with(new SecurityProviderImpl());
>         Repository repository = jcr.createRepository();
>         Session session = repository.login(ADMIN_CREDENTIALS);
>         Node myNode = session.getRootNode().addNode("myNode");
>         myNode.setProperty("text", "hello_world");
>         session.save();
>         QueryManager qm = session.getWorkspace().getQueryManager();
>         Query q = qm.createQuery("select * from [nt:base] where CONTAINS([text],'hello_world')", Query.JCR_SQL2);
>         QueryResult execute = q.execute();
>         long foundNodes = execute.getNodes().getSize();
>         session.logout();
>         fileStore.close();
>         ((JackrabbitRepository) repository).shutdown();
>         assertEquals(1L, foundNodes);
>     }
> {code}
> The test fails because the query return 0 results while it should return 1. It works fine if instead of executing:
> {code} select * from [nt:base] where CONTAINS([text],'hello_world') {code}
> I run it using the LIKE operator:
> {code} select * from [nt:base] where [text] LIKE 'hello_world' {code}
> I also tried to run the same test inside the _org.apache.jackrabbit.oak.jcr.query.QueryTest.java_, but there it works fine. Here the test i run:
> {code}
>     @Test
>     public void shouldFindNodeUsingContainsOperator() throws RepositoryException {
>         Session session = getAdminSession();
>         Node hello = session.getRootNode().addNode("hello");
>         hello.setProperty("text", "hello_world");
>         session.save();
>         QueryManager qm = session.getWorkspace().getQueryManager();
>         Query q = qm.createQuery("select * from [nt:base] where CONTAINS([text],'hello_world')", Query.JCR_SQL2);
>         QueryResult r = q.execute();
>         NodeIterator nodes = r.getNodes();
>         assertEquals(1, nodes.getSize());
>     }
> {code}
> Marco.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)