Hello,

I'm trying to get native Lucene queries working, but get no results.My Oak version is jcr.repository.version: 1.3.7

I followed the Oak/Lucene guide here:https://jackrabbit.apache.org/oak/docs/query/lucene.html#native-query

I can open the actual Lucene index withLUKE <https://github.com/tarzanek/luke> and I am able to run the following query and get one result: merchant_id:merchant-704658


When I run the equivalent query in Sling/OAK I get no results:

SQL
select [jcr:path] from [nt:base] where native('LuceneIndexTest', 'merchant_id:(merchant-704658)')

24.02.2016 15:54:43.078 *DEBUG* [192.168.1.1 [1456347283078] GET /content.query.json HTTP/1.1] org.apache.jackrabbit.oak.query.QueryEngineImpl Parsing sql statement: select [jcr:path] from [nt:base] where native('LuceneIndexTest', 'merchant_id:merchant-704658') 24.02.2016 15:54:43.078 *TRACE* [192.168.1.1 [1456347283078] GET /content.query.json HTTP/1.1] org.apache.jackrabbit.oak.query.SQL2Parser Literal used 24.02.2016 15:54:43.078 *DEBUG* [192.168.1.1 [1456347283078] GET /content.query.json HTTP/1.1] org.apache.jackrabbit.oak.query.QueryImpl cost using filter Filter(query=select [jcr:path] from [nt:base] where native('LuceneIndexTest', 'merchant_id:merchant-704658'), path=*, property=[native*LuceneIndexTest=[merchant_id:merchant-704658]]) 24.02.2016 15:54:43.078 *DEBUG* [192.168.1.1 [1456347283078] GET /content.query.json HTTP/1.1] org.apache.jackrabbit.oak.query.QueryImpl cost for reference is Infinity 24.02.2016 15:54:43.078 *DEBUG* [192.168.1.1 [1456347283078] GET /content.query.json HTTP/1.1] org.apache.jackrabbit.oak.query.QueryImpl cost for nodeType is Infinity 24.02.2016 15:54:43.078 *DEBUG* [192.168.1.1 [1456347283078] GET /content.query.json HTTP/1.1] org.apache.jackrabbit.oak.query.QueryImpl cost for property is Infinity 24.02.2016 15:54:43.078 *TRACE* [192.168.1.1 [1456347283078] GET /content.query.json HTTP/1.1] org.apache.jackrabbit.oak.plugins.index.lucene.IndexPlanner Evaluating plan with index definition Lucene Index : LuceneIndexTest(/oak:index/LuceneIndexTest) 24.02.2016 15:54:43.078 *TRACE* [192.168.1.1 [1456347283078] GET /content.query.json HTTP/1.1] org.apache.jackrabbit.oak.plugins.index.lucene.IndexPlanner Evaluating plan with index definition Lucene Index : /oak:index/lucene 24.02.2016 15:54:43.078 *DEBUG* [192.168.1.1 [1456347283078] GET /content.query.json HTTP/1.1] org.apache.jackrabbit.oak.query.QueryImpl cost for lucene-property[/oak:index/LuceneIndexTest] is 2.0 24.02.2016 15:54:43.078 *DEBUG* [192.168.1.1 [1456347283078] GET /content.query.json HTTP/1.1] org.apache.jackrabbit.oak.query.QueryImpl cost for traverse is Infinity 24.02.2016 15:54:43.078 *DEBUG* [192.168.1.1 [1456347283078] GET /content.query.json HTTP/1.1] org.apache.jackrabbit.oak.query.QueryImpl query execute select [jcr:path] from [nt:base] where native('LuceneIndexTest', 'merchant_id:merchant-704658') 24.02.2016 15:54:43.079 *DEBUG* [192.168.1.1 [1456347283078] GET /content.query.json HTTP/1.1] org.apache.jackrabbit.oak.query.QueryImpl query plan [nt:base] as [nt:base] /* lucene:LuceneIndexTest(/oak:index/LuceneIndexTest) merchant_id:merchant merchant_id:704658 where native([nt:base], [LuceneIndexTest], 'merchant_id:merchant-704658') */ 24.02.2016 15:54:43.079 *DEBUG* [192.168.1.1 [1456347283078] GET /content.query.json HTTP/1.1] org.apache.jackrabbit.oak.plugins.index.lucene.LucenePropertyIndex loading the first 50 entries for query merchant_id:merchant merchant_id:704658 24.02.2016 15:54:43.080 *TRACE* [192.168.1.1 [1456347283078] GET /content.query.json HTTP/1.1] org.apache.jackrabbit.oak.plugins.index.lucene.LucenePropertyIndex.perf 0 ... [took 1ms]

---------------------------------------------------------------------------------------------
or XPATH
//*[rep:native('LuceneIndexTest', 'merchant-704658')]

24.02.2016 15:56:27.138 *DEBUG* [192.168.1.1 [1456347387138] GET /content.query.json HTTP/1.1] org.apache.jackrabbit.oak.query.QueryEngineImpl Parsing xpath statement: //*[rep:native('LuceneIndexTest', 'merchant_id:merchant-704658')] 24.02.2016 15:56:27.138 *DEBUG* [192.168.1.1 [1456347387138] GET /content.query.json HTTP/1.1] org.apache.jackrabbit.oak.query.QueryEngineImpl XPath > SQL2: select [jcr:path], [jcr:score], * from [nt:base] as a where native(a, 'LuceneIndexTest', 'merchant_id:merchant-704658') /* xpath: //*[rep:native('LuceneIndexTest', 'merchant_id:merchant-704658')] */ 24.02.2016 15:56:27.138 *TRACE* [192.168.1.1 [1456347387138] GET /content.query.json HTTP/1.1] org.apache.jackrabbit.oak.query.SQL2Parser Literal used 24.02.2016 15:56:27.138 *DEBUG* [192.168.1.1 [1456347387138] GET /content.query.json HTTP/1.1] org.apache.jackrabbit.oak.query.QueryImpl cost using filter Filter(query=select [jcr:path], [jcr:score], * from [nt:base] as a where native(a, 'LuceneIndexTest', 'merchant_id:merchant-704658') /* xpath: //*[rep:native('LuceneIndexTest', 'merchant_id:merchant-704658')] */, path=*, property=[native*LuceneIndexTest=[merchant_id:merchant-704658]]) 24.02.2016 15:56:27.138 *DEBUG* [192.168.1.1 [1456347387138] GET /content.query.json HTTP/1.1] org.apache.jackrabbit.oak.query.QueryImpl cost for reference is Infinity 24.02.2016 15:56:27.138 *DEBUG* [192.168.1.1 [1456347387138] GET /content.query.json HTTP/1.1] org.apache.jackrabbit.oak.query.QueryImpl cost for nodeType is Infinity 24.02.2016 15:56:27.138 *DEBUG* [192.168.1.1 [1456347387138] GET /content.query.json HTTP/1.1] org.apache.jackrabbit.oak.query.QueryImpl cost for property is Infinity 24.02.2016 15:56:27.138 *TRACE* [192.168.1.1 [1456347387138] GET /content.query.json HTTP/1.1] org.apache.jackrabbit.oak.plugins.index.lucene.IndexPlanner Evaluating plan with index definition Lucene Index : LuceneIndexTest(/oak:index/LuceneIndexTest) 24.02.2016 15:56:27.138 *TRACE* [192.168.1.1 [1456347387138] GET /content.query.json HTTP/1.1] org.apache.jackrabbit.oak.plugins.index.lucene.IndexPlanner Evaluating plan with index definition Lucene Index : /oak:index/lucene 24.02.2016 15:56:27.138 *DEBUG* [192.168.1.1 [1456347387138] GET /content.query.json HTTP/1.1] org.apache.jackrabbit.oak.query.QueryImpl cost for lucene-property[/oak:index/LuceneIndexTest] is 2.0 24.02.2016 15:56:27.138 *DEBUG* [192.168.1.1 [1456347387138] GET /content.query.json HTTP/1.1] org.apache.jackrabbit.oak.query.QueryImpl cost for traverse is Infinity 24.02.2016 15:56:27.138 *DEBUG* [192.168.1.1 [1456347387138] GET /content.query.json HTTP/1.1] org.apache.jackrabbit.oak.query.QueryImpl query execute select [jcr:path], [jcr:score], * from [nt:base] as a where native(a, 'LuceneIndexTest', 'merchant_id:merchant-704658') /* xpath: //*[rep:native('LuceneIndexTest', 'merchant_id:merchant-704658')] */ 24.02.2016 15:56:27.139 *DEBUG* [192.168.1.1 [1456347387138] GET /content.query.json HTTP/1.1] org.apache.jackrabbit.oak.query.QueryImpl query plan [nt:base] as [a] /* lucene:LuceneIndexTest(/oak:index/LuceneIndexTest) merchant_id:merchant merchant_id:704658 where native([a], [LuceneIndexTest], 'merchant_id:merchant-704658') */ 24.02.2016 15:56:27.139 *DEBUG* [192.168.1.1 [1456347387138] GET /content.query.json HTTP/1.1] org.apache.jackrabbit.oak.plugins.index.lucene.LucenePropertyIndex loading the first 50 entries for query merchant_id:merchant merchant_id:704658 24.02.2016 15:56:27.139 *TRACE* [192.168.1.1 [1456347387138] GET /content.query.json HTTP/1.1] org.apache.jackrabbit.oak.plugins.index.lucene.LucenePropertyIndex.perf 0 ... [took 0ms]

---------------------------------------------------------------------------------------------
My custom Lucene Index definition looks like this (you can see I specified the functionName as above):

{
"jcr:primaryType": "oak:QueryIndexDefinition",
"compatVersion": 2,
"functionName": "LuceneIndexTest",
"name": "LuceneIndexTest",
"type": "lucene",
"async": "async",
"evaluatePathRestrictions": true,
"reindex": false,
"reindexCount": 4,
"indexRules": {
    "jcr:primaryType": "nt:unstructured",
    "nt:base": {
            "jcr:primaryType": "nt:unstructured",
            "includePropertyTypes": "[String, Date]",
            "properties": {
                    "jcr:primaryType": "nt:unstructured",
                    "jcr:lastModified": {
                            "jcr:primaryType": "nt:unstructured",
                            "ordered": true,
                            "propertyIndex": true,
                            "name": "jcr:content/jcr:lastModified",
                            "type": "Date",
                            "nodeName": "lastModified"
                    },
                    "jcr:primaryType": {
                            "jcr:primaryType": "nt:unstructured",
                            "ordered": false,
                            "propertyIndex": true,
                            "name": "jcr:primaryType",
                            "type": "String",
                            "nodeName": "jcr:primaryType"
                    },
                    "merchant_id": {
                            "jcr:primaryType": "nt:unstructured",
                            "propertyIndex": true,
                            "analyzed": true,
                            "index": true,
                            "name": "merchant_id"
                    }
            }
    },
    "oak:Unstructured": {
            "jcr:primaryType": "nt:unstructured",
            "includePropertyTypes": "[String, Date]",
            "properties": {
                    "jcr:primaryType": "nt:unstructured",
                    "jcr:lastModified": {
                            "jcr:primaryType": "nt:unstructured",
                            "ordered": true,
                            "propertyIndex": true,
                            "name": "jcr:content/jcr:lastModified",
                            "type": "Date",
                            "nodeName": "lastModified"
                    },
                    "jcr:primaryType": {
                            "jcr:primaryType": "nt:unstructured",
                            "ordered": false,
                            "propertyIndex": true,
                            "name": "jcr:primaryType",
                            "type": "String",
                            "nodeName": "jcr:primaryType"
                    },
                    "merchant_id": {
                            "jcr:primaryType": "nt:unstructured",
                            "propertyIndex": true,
                            "analyzed": true,
                            "index": true,
                            "name": "merchant_id",
                            "nodeName": "merchant_id"
                    }
            }
    }
        }
}

It appears that this functionality is not working. I found a relatedOAK JIRA ticket <https://issues.apache.org/jira/browse/OAK-2205> and someone left a message indicating: "The feature would not work with LucenePropertyIndex due to OAK-2241".

Any suggestions are greatly appreciated.

--
--Leo

Reply via email to