[
https://issues.apache.org/jira/browse/DERBY-6602?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Rick Hillegas updated DERBY-6602:
---------------------------------
Attachment: derby-6602-01-aa-handleNullKeys.diff
Attaching derby-6602-01-aa-handleNullKeys.diff. This patch adds support for
null key values. The Lucene tests pass cleanly for me using this patch.
There were two problems:
1) The scan of the table/view (when creating the index) wasn't checking for
null values.
2) The query vti wasn't checking for null values either.
Touches the following files:
M java/optional/org/apache/derby/optional/lucene/LuceneQueryVTI.java
M java/optional/org/apache/derby/optional/lucene/LuceneSupport.java
M
java/testing/org/apache/derbyTesting/functionTests/tests/lang/LuceneSupportPermsTest.java
> LuceneQueryVTI handles NULL key values inconsistently
> -----------------------------------------------------
>
> Key: DERBY-6602
> URL: https://issues.apache.org/jira/browse/DERBY-6602
> Project: Derby
> Issue Type: Bug
> Components: Tools
> Affects Versions: 10.11.0.0
> Reporter: Knut Anders Hatlen
> Attachments: derby-6602-01-aa-handleNullKeys.diff
>
>
> If there's an integer key column with a NULL value, the Lucene query will
> return a fake key value (0) rather than NULL. The document id and score will
> be correct. Example:
> {noformat}
> ij> create table t1(x int, c clob);
> 0 rows inserted/updated/deleted
> ij> insert into t1 values (null, 'abc'), (null, 'def');
> 2 rows inserted/updated/deleted
> ij> call lucenesupport.createindex('app', 't1', 'c', null, 'x');
> 0 rows inserted/updated/deleted
> ij> select * from table(t1__c('abc or def', null, 3, null)) tc;
> X |DOCUMENTID |SCORE
> ---------------------------------------
> 0 |0 |0.35355338
> 0 |1 |0.35355338
> 2 rows selected
> {noformat}
> If the key column is a string type, the returned key is correct (NULL). The
> document id is sometimes correct and sometimes NULL, and the score seems to
> be NULL always. Example:
> {noformat}
> ij> create table t2(x varchar(10), c clob);
> 0 rows inserted/updated/deleted
> ij> insert into t2 values (null, 'abc'), (null, 'def');
> 2 rows inserted/updated/deleted
> ij> call lucenesupport.createindex('app', 't2', 'c', null, 'x');
> 0 rows inserted/updated/deleted
> ij> select * from table(t2__c('abc or def', null, 3, null)) tc;
> X |DOCUMENTID |SCORE
> --------------------------------------
> NULL |NULL |NULL
> NULL |1 |NULL
> 2 rows selected
> {noformat}
--
This message was sent by Atlassian JIRA
(v6.2#6252)