Make script cache configurable and bounded

Fixes #2539
Fix char filter issues introduced during lucene 4 migration

Fixes #2543