[
https://issues.apache.org/jira/browse/OAK-6418?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16074839#comment-16074839
]
Marco Piovesana commented on OAK-6418:
--------------------------------------
Hi Davide,
yes I did read the documentation about the query engine. But I'm not sure that
I get your point: do you mean that without a fulltext index the "_CONTAINS_"
operator does not work? Isn't this in contrast with what's written in the query
engine documentation? (??If there is no index for a specific query, then the
repository will be traversed. That is, the query will still work but probably
be very slow??).
Marco.
> 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)