Common Development Tasks
Adding a New Facet Field
- •Update
DocumentIndexer.java- add the field toFacetsConfig - •Add the field to the Lucene document in the indexing method
- •Update README.md field schema table
- •Note: This is a breaking change -- requires full reindex of all documents
Adding File Format Support
- •Add the file extension pattern to
application.yamlunderinclude-patterns - •Apache Tika handles most formats automatically via auto-detection
- •For custom parsing beyond Tika: extend
FileContentExtractor.java - •Test with real documents of the new format
- •Update README.md supported formats section
Debugging STDIO Issues
The MCP server uses STDIO transport. Any output to stdout breaks the JSON-RPC protocol.
Checklist:
- •Must use
deployedprofile:java -Dspring.profiles.active=deployed -jar target/luceneserver-*.jar - •The
deployedprofile disables all console logging appenders - •Search for
System.out.printlnin codebase -- there must be NONE - •Search for
System.err.println-- also problematic - •Logger output goes to file only in deployed mode
- •Test command:
java -Dspring.profiles.active=deployed -jar target/luceneserver-*.jar
Performance Tuning
Indexing is slow
- •Increase
thread-pool-sizein config (more parallel file walkers) - •Increase
batch-size(fewer Lucene commits) - •Increase
batch-timeout-ms(larger batches) - •Check if
max-content-lengthis causing excessive content truncation
Search is slow
- •Check for leading wildcard queries (
*term) -- these are expensive even withcontent_reversedoptimization - •Reduce
pageSizein search requests - •Check total index size -- very large indices may benefit from
optimizeIndex()
Out of Memory (OOM)
- •Set
max-content-lengthto limit per-document content size - •Increase JVM heap:
-Xmx2gor higher - •Reduce
thread-pool-size(each thread holds document content in memory) - •Check for very large files being indexed (e.g., multi-GB archives)
Adding a New Indexed Field
WARNING: Adding a new indexed field is a breaking change. Existing documents in the index will not have the new field.
Steps:
- •Add field in
DocumentIndexer.javadocument creation - •If field needs special analysis: update
PerFieldAnalyzerWrapperinLuceneIndexService - •If field should be searchable: update query parsing in
LuceneIndexService - •If field should be highlighted: ensure it has
Store.YESand term vectors - •Update README.md field schema table
- •Document in README.md that reindex is required
- •Test with
SearchHighlightingIntegrationTestpatterns
Testing Patterns
- •Integration tests use
@TempDirfor isolated Lucene indices - •Mock
ApplicationConfigfor configuration - •Helper
indexDocument(Path)extracts, creates doc, indexes, commits, refreshes - •Run all tests:
mvn test(~88 tests, ~10 seconds) - •Run specific test:
mvn test -Dtest=SearchHighlightingIntegrationTest