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

Thomas Mueller commented on OAK-319:
------------------------------------

I think that "rep:similar" could be supported by converting it to a native 
lucene query, as follows:

{noformat}
    @Test
    public void testRepSimilarQuery() throws Exception {
        String nativeQueryString = "select [jcr:path] from [nt:base] where 
native('lucene', 
'mlt?stream.body=/test/a&mlt.fl=my:path&mlt.mindf=0&mlt.mintf=0')";
        Tree test = root.getTree("/").addChild("test");
        test.addChild("a").setProperty("my:path", "/test/a");
        test.addChild("a").setProperty("text", "Hello World");
        test.addChild("b").setProperty("my:path", "/test/b");
        test.addChild("b").setProperty("text", "He said Hello World and then 
the world said Hello as well.");
        test.addChild("b").setProperty("my:path", "/test/c");
        test.addChild("b").setProperty("text", "He said Hi and then the world 
said Hi as well.");
        root.commit();
        Iterator<String> result = executeQuery(nativeQueryString, 
"JCR-SQL2").iterator();
        assertTrue(result.hasNext());
        assertEquals("/test/a", result.next());
        assertTrue(result.hasNext());
        assertEquals("/test/b", result.next());
        assertFalse(result.hasNext());
    }
{noformat}

The problem is that the path of a node (the ":path" field in Lucene) is not 
indexed. [~alex.parvulescu], would it be OK to index this field, or do you 
think that would be problematic (for performance or other reasons)?

> Similar (rep:similar) support
> -----------------------------
>
>                 Key: OAK-319
>                 URL: https://issues.apache.org/jira/browse/OAK-319
>             Project: Jackrabbit Oak
>          Issue Type: Sub-task
>          Components: jcr, query
>            Reporter: Alex Parvulescu
>            Assignee: Thomas Mueller
>            Priority: Critical
>             Fix For: 0.20
>
>
> Test class is: SimilarQueryTest
> Trace:
> {noformat}
> Caused by: java.text.ParseException: Query:
> //*[rep:similar(.(*), '/testroot')]; expected: rep:similar is not supported
>       at 
> org.apache.jackrabbit.oak.query.XPathToSQL2Converter.getSyntaxError(XPathToSQL2Converter.java:963)
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to