A monorepo containing tools and libraries for Apache Lucene query language support across multiple platforms.
Platform-agnostic core library providing:
- Lucene query tokenization and parsing
- Syntax tree analysis
- Completion suggestion generation
- Field schema validation
Monaco Editor integration providing:
- Syntax highlighting with Monarch tokenizer
- Light and dark themes
- Intelligent auto-completion
- Context-aware suggestions
React web application featuring:
- Monaco-based Lucene query editor
- Real-time syntax highlighting
- Configurable field schemas
- Responsive design with Tailwind CSS
π¨ Transform your Lucene queries in VS Code!
This extension makes writing Apache Lucene queries a breeze with:
- π Beautiful syntax highlighting for
.lucene
files - π§ Smart auto-completion as you type
- βοΈ Customizable field schemas for your specific use case
- π Real-time error detection to catch mistakes early
- π Snippet support for common query patterns
Install the packages you need from npm:
# Core parsing library
pnpm add @lucene-tools/core
# Monaco Editor integration
pnpm add @lucene-tools/monaco-language
# Both packages together
pnpm add @lucene-tools/core @lucene-tools/monaco-language
Install from VS Code Marketplace:
- Open VS Code
- Go to Extensions (Ctrl+Shift+X)
- Search for "Lucene Language Support"
- Click Install
Or install from command line:
code --install-extension lucene-language-support
import { tokenize, parse, generateCompletions } from '@lucene-tools/core';
// Tokenize a Lucene query
const tokens = tokenize('field:value AND status:active');
// Parse query for context analysis
const context = parse('field:val');
// Generate completions
const schema = {
fields: ['title', 'description', 'status'],
values: { status: ['active', 'inactive', 'pending'] }
};
const completions = generateCompletions('stat', schema);
import * as monaco from 'monaco-editor';
import { registerLuceneLanguage } from '@lucene-tools/monaco-language';
// Register Lucene language support
registerLuceneLanguage(monaco, {
schema: {
fields: ['title', 'description', 'status'],
values: { status: ['active', 'inactive', 'pending'] }
}
});
// Create editor with Lucene support
const editor = monaco.editor.create(document.getElementById('editor'), {
value: 'title:"hello world" AND status:active',
language: 'lucene',
theme: 'lucene-dark'
});
Getting Started:
- Create a file with
.lucene
extension (e.g.,search-queries.lucene
) - Start typing your Lucene query - syntax highlighting activates automatically
- Use Ctrl+Space to trigger auto-completion suggestions
Example queries to try:
// Basic field search
title:"hello world" AND status:active
// Range queries with dates
created:[2023-01-01 TO 2023-12-31]
// Fuzzy search with boost
title:search~0.8^2 OR description:find
// Complex boolean query
(category:technology OR category:science) AND published:true
Configure field schemas by adding to your VS Code settings:
{
"lucene.fieldSchema": {
"fields": ["title", "description", "category", "status", "published"],
"values": {
"status": ["active", "inactive", "pending"],
"category": ["technology", "science", "business"],
"published": ["true", "false"]
}
}
}
- Node.js 18+
- pnpm 8+
pnpm install
# Build all packages
pnpm build
# Start web editor development server
pnpm dev
# Run tests across all packages
pnpm test
# Lint all packages
pnpm lint
lucene-language-tools/
βββ packages/
β βββ core/ # Platform-agnostic core logic
β βββ monaco-language/ # Monaco Editor integration
β βββ web-editor/ # React web application
β βββ vscode-extension/ # VS Code extension
βββ package.json # Root workspace configuration
βββ pnpm-workspace.yaml # pnpm workspace setup
@lucene-tools/core
β No dependencies (pure TypeScript)@lucene-tools/monaco-language
β Depends on core + Monaco Editor@lucene-tools/web-editor
β Depends on monaco-language + Reactlucene-language-support
β Depends on core + VS Code API
# Add to specific package
pnpm --filter @lucene-tools/core add <dependency>
# Add to root workspace
pnpm add -w <dependency>
# Build all packages
pnpm -r build
# Build specific package
pnpm --filter @lucene-tools/core build
# Test all packages
pnpm -r test
# Test with coverage
pnpm -r test:coverage
- Field queries:
field:value
,"quoted field":value
- Comparison operators:
>
,>=
,<
,<=
,=
- Boolean operators:
AND
,OR
,NOT
,&&
,||
,!
- Range queries:
[start TO end]
,{start TO end}
- Unbounded ranges:
[value TO *]
,[* TO value]
- Wildcard searches:
*
,?
- Fuzzy search:
term~0.8
- Proximity search:
"phrase"~10
- Boost queries:
term^2.5
- Regular expressions:
/pattern/
- Date formats: ISO 8601, US format
- Escaped characters:
\\
,\+
,\-
, etc.
- Context-aware field suggestions
- Field-specific value completions
- Operator and keyword suggestions
- Snippet completions for complex patterns
- Configurable field schemas
Both light and dark themes with distinct colors for:
- Field names (blue)
- Keywords (purple)
- Operators (various colors by type)
- Strings and dates (orange/red)
- Numbers (green)
- Regular expressions (red)
MIT License - see individual packages for details.
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Run
pnpm build
andpnpm test
- Submit a pull request