Overview
Groovy is the default scripting language for Fess. It runs on the Java Virtual Machine (JVM) and, while maintaining high compatibility with Java, allows you to write scripts with a more concise syntax.
Basic Syntax
Variable Declaration
String Operations
Collection Operations
Conditional Branching
Loop Processing
Data Store Scripts
Examples of scripts for data store configuration.
Basic Mapping
URL Generation
Content Processing
Date Processing
Scheduled Job Scripts
Examples of Groovy scripts used in scheduled jobs.
Execute Crawl Job
Conditional Crawling
Execute Multiple Jobs Sequentially
Using Java Classes
Within Groovy scripts, you can use Java standard libraries and Fess classes.
Date and Time
File Operations
HTTP Communication
Warning
Access to external resources affects performance, so keep it to a minimum.
Accessing Fess Components
You can access Fess components using container.
System Helper
Getting Configuration Values
Executing Searches
Error Handling
Debugging and Log Output
Log Output
Debug Output
Best Practices
Keep it simple: Avoid complex logic and write readable code
Null checks: Utilize
?.and?:operatorsException handling: Handle unexpected errors with appropriate try-catch
Log output: Output logs for easier debugging
Performance: Minimize external resource access
Reference Information
Scripting Overview - Scripting Overview
Data Store Crawling - Data Store Configuration Guide
Scheduler - Scheduler Configuration Guide