I think maybe you just need to escape the '-' ?

http://stackoverflow.com/questions/17839053/how-to-perform-a-lucene-query-containing-special-character-using-queryparser


Best regards,
Clay Ferguson
[email protected]


On Thu, Feb 25, 2016 at 11:56 AM, Leonardo Rodriguez-Velez <
[email protected]> wrote:

> Hello all,
>
> After some more testing it appears that queries of the form:
>
> select [jcr:path] from [nt:base] where native('LuceneIndexTest',
> 'merchant_id:merchant-*')
> select [jcr:path] from [nt:base] where native('LuceneIndexTest',
> 'merchant_id:merchant-?')
> select [jcr:path] from [nt:base] where native('LuceneIndexTest',
> 'merchant_id:merchant-~')
>
> do work. These queries are the wildcard and fuzzy match queries in the
> native Lucene language and I believe require a fulltext index.
>
> However, I would like to query for a specific value like this:
>
> select [jcr:path] from [nt:base] where native('LuceneIndexTest',
> 'merchant_id:merchant-1')
>
> I've tried several combinations, with and without quotes and escaped
> quotes around merchant-1, and I get zero results.
>
> https://issues.apache.org/jira/browse/OAK-2241 Indicates that :
> " Currently, native queries are only supported for full-text indexes. The
> LuceneProperty index would also benefit from that. So I think we need to
> add a new marker interface, NativeQueryIndex, so we can support it."
>
> This ticket was supposed to add support for "LuceneProperty index", which
> I assume means non-fulltext queries should be supported.
>
> So, are exact match Field queries such as described here:
> https://lucene.apache.org/core/2_9_4/queryparsersyntax.html#Fields
> supported or not?
>
> --Leo
>
> On 2/24/16 3:58 PM, Leonardo Rodriguez-Velez wrote:
>
>> 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.
>>
>>
>

Reply via email to