It looks like you are attempting to implement a FunctionScoreQuery. This class doesn't itself know anything about Lucene, only some implementations do (like ScriptScoreFunction). Maybe consider using an advanced script instead. The docs for writing native scripts (through a custom script engine) explain how to access Lucene data structures.