Claus Ibsen created CAMEL-27835:
-----------------------------------

             Summary: camel-lucene: the component options are never used, the 
default index directory is file:/indexDirectory, maxHits is not checked
                 Key: CAMEL-27835
                 URL: https://issues.apache.org/jira/browse/CAMEL-27835
             Project: Camel
          Issue Type: Bug
          Components: camel-lucene
            Reporter: Claus Ibsen
             Fix For: 4.25.0


Found while improving the option descriptions of camel-lucene for CAMEL-23832 
(pull request https://github.com/apache/camel/pull/31142).
These are separate problems of the component; the descriptions change only 
documents the current behavior.

h4. 1. The component configuration is never used
{{LuceneComponent.createEndpoint}} / {{LuceneConfiguration.parseURI}} overwrite 
every field of the copied component config with the URI value or a hard-coded 
default (new StandardAnalyzer(), new File("file:///./indexDirectory"), 10), so 
the component-level analyzer, indexDir, maxHits and srcDir are never used.
Proposed change: fall back to the value of the copied config instead of the 
hard-coded default.

h4. 2. The default index directory is the relative path file:/indexDirectory
The default new File("file:///./indexDirectory") becomes the relative path 
file:/indexDirectory, so a directory named "file:" is made in the working 
directory (an invalid name on Windows). LuceneIndexer.mkdir() fails because the 
parent is missing and logs an ERROR, then Lucene FSDirectory creates it anyway.
Proposed change: default to new File("indexDirectory"), use mkdirs() or let 
FSDirectory create it, and remove the dead ./indexDirectory fallbacks.

h4. 3. maxHits of 0 or less is not checked
Every query then fails with IllegalArgumentException "numHits must be > 0" from 
Lucene.
Proposed change: validate at endpoint creation.

h4. 4. The error message names the wrong header
LuceneQueryProducer and LuceneQueryProcessor say "Set the Header value: QUERY"; 
the header is CamelLuceneQuery.
Proposed change: fix the message.


_Claude Code on behalf of davsclaus_



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

Reply via email to