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

Paul Chibulcuteanu updated OAK-12509:
-------------------------------------
    Description: 
An index can be given tags with the  tags  property, and a query can then 
select it with  option(index tag ...) . However, the query parser only accepts 
the characters  a-z, A-Z, 0-9, _  in the tag value. Any tag with a hyphen ( - ) 
or a dot ( . ) is rejected as a syntax error, even when it exactly matches a 
tag configured on the index.

Index names have no such restriction.  option(index name ...)  works with names 
that contain these characters, for example  damAssetLucene-12-custom-1 .

Steps to reproduce:

 1. Configure an index with:
 {code}
 "tags": ["personalization", "pages", "semantic-pages", "semantic.pages"]
 {code}
 2. Run a query with  option(index tag pages) . It works.
 3. Run the same query with  option(index tag semantic-pages)  or  option(index 
tag semantic.pages) , either bare, quoted or in brackets. It fails with a parse 
error:  expected: a-z, A-Z, 0-9, _ .
 4. Run the same query with  option(index name damAssetLucene-12-custom-1) . It 
works.

Expected:
Tag values with  -  and  .  are accepted, the same way index names are, and the 
index whose  tags  contain that value is selected.

Actual:
The query is rejected with a parse error before index selection happens.

Cause:
The tag value is checked against  [a-zA-Z0-9_]* . Index names are not checked 
this way.

Proposed fix:
Allow  -  and  .  in index tag values. Keep the existing length limit, and keep 
rejecting other characters. Update the documentation ( query-engine.md ) to 
match.

Once you've added it, I can update PR #3265 to accept  .  as well.


  was:
Hyphenated index names work for explicit index selection, but hyphenated index 
tags fail—even when quoted or bracket-delimited.

The index definition includes:

 "tags": ["personalization", "pages", "semantic-pages"]

Using the same query, the following options succeed:

 OPTION(INDEX NAME [damAssetLucene-12-custom-1])
 OPTION(INDEX TAG [pages])

However, selecting the configured hyphenated tag fails:

 OPTION(INDEX TAG [semantic-pages])

Expected behavior

Configured hyphenated index tags should be usable for index selection, 
consistently with support for hyphenated index names.

Actual behavior / cause

Index-tag values undergo additional validation in  SQL2Parser.readLabel() , 
allowing only letters, digits, and underscores ( [a-zA-Z0-9_]* ). Quoting does 
not bypass this validation. Index names use  readName()  without this 
additional restriction.

Source: 
https://github.com/apache/jackrabbit-oak/blob/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/SQL2Parser.java

Impact

A hyphenated tag can exist in an index definition but cannot be used to select 
that index. Workarounds include adding an underscore-based tag or selecting the 
index by name.

The restriction is currently documented; this requests aligning index-tag 
handling with index-name handling, rather than reporting a confirmed regression.



> Index tag option rejects tag values containing  -  or  . , unlike index names
> -----------------------------------------------------------------------------
>
>                 Key: OAK-12509
>                 URL: https://issues.apache.org/jira/browse/OAK-12509
>             Project: Jackrabbit Oak
>          Issue Type: Task
>          Components: indexing
>    Affects Versions: 1.2.22
>            Reporter: Paul Chibulcuteanu
>            Priority: Minor
>
> An index can be given tags with the  tags  property, and a query can then 
> select it with  option(index tag ...) . However, the query parser only 
> accepts the characters  a-z, A-Z, 0-9, _  in the tag value. Any tag with a 
> hyphen ( - ) or a dot ( . ) is rejected as a syntax error, even when it 
> exactly matches a tag configured on the index.
> Index names have no such restriction.  option(index name ...)  works with 
> names that contain these characters, for example  damAssetLucene-12-custom-1 .
> Steps to reproduce:
>  1. Configure an index with:
>  {code}
>  "tags": ["personalization", "pages", "semantic-pages", "semantic.pages"]
>  {code}
>  2. Run a query with  option(index tag pages) . It works.
>  3. Run the same query with  option(index tag semantic-pages)  or  
> option(index tag semantic.pages) , either bare, quoted or in brackets. It 
> fails with a parse error:  expected: a-z, A-Z, 0-9, _ .
>  4. Run the same query with  option(index name damAssetLucene-12-custom-1) . 
> It works.
> Expected:
> Tag values with  -  and  .  are accepted, the same way index names are, and 
> the index whose  tags  contain that value is selected.
> Actual:
> The query is rejected with a parse error before index selection happens.
> Cause:
> The tag value is checked against  [a-zA-Z0-9_]* . Index names are not checked 
> this way.
> Proposed fix:
> Allow  -  and  .  in index tag values. Keep the existing length limit, and 
> keep rejecting other characters. Update the documentation ( query-engine.md ) 
> to match.
> Once you've added it, I can update PR #3265 to accept  .  as well.



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

Reply via email to