[ 
https://issues.apache.org/jira/browse/OAK-12564?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Thomas Mueller reassigned OAK-12564:
------------------------------------

    Assignee: Thomas Mueller

> Lucene: function index property with a declared type is indexed as a string, 
> so range queries on it return no rows
> ------------------------------------------------------------------------------------------------------------------
>
>                 Key: OAK-12564
>                 URL: https://issues.apache.org/jira/browse/OAK-12564
>             Project: Jackrabbit Oak
>          Issue Type: Bug
>          Components: lucene
>            Reporter: Benjamin Habegger
>            Assignee: Thomas Mueller
>            Priority: Major
>
> A property definition with a {{function}} and a {{type}} (for example 
> {{Date}}) is indexed on Lucene with the type of the function result, not the 
> declared type. The query side uses the declared type. Range queries on the 
> function then return no rows.
> Index definition (excerpt):
> {noformat}
> + indexRules/cq:Page/properties/createdModifiedCombined
>   - function = "fn:coalesce(jcr:content/@cq:lastModified, @jcr:created)"
>   - type = "Date"
>   - propertyIndex = true
>   - ordered = true
> {noformat}
> Query:
> {noformat}
> SELECT * FROM [cq:Page]
> WHERE COALESCE([jcr:content/cq:lastModified], [jcr:created]) > 
> CAST('2026-01-01T00:00:00.000Z' AS DATE)
> {noformat}
> Expected: the pages whose coalesced date is after 2026-01-01.
> Actual (Lucene): no rows. The query sends a numeric range, but the values are 
> indexed as string terms. Without {{type}}, the same query returns the 
> expected rows.
> Elasticsearch is not affected: it converts the value to the declared type 
> before indexing.
> h3. Proposed fix
> When a function property declares a type, convert the function value to that 
> type before indexing on Lucene, as Elasticsearch does. Skip and log values 
> that cannot be converted. Function properties without a type keep the current 
> behaviour.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to