Class JavascriptCompiler
An expression compiler for javascript expressions.
Inheritance
System.Object
JavascriptCompiler
Assembly: Lucene.Net.Expressions.dll
Syntax
public class JavascriptCompiler : object
Remarks
An expression compiler for javascript expressions.
Example:
Expression foo = JavascriptCompiler.Compile("((0.3*popularity)/10.0)+(0.7*score)");
See the Lucene.Net.Expressions.JS for the supported syntax and default functions.
You can compile with an alternate set of functions via Compile(String, IDictionary<String, MethodInfo>). For example:
IDictionary<string, MethodInfo> functions = new Dictionary<string, MethodInfo>();
// add all the default functions
functions.PutAll(JavascriptCompiler.DEFAULT_FUNCTIONS);
// add sqrt()
functions.Put("sqrt", (typeof(Math)).GetMethod("Sqrt", new Type[] { typeof(double) }));
// call compile with customized function map
Expression foo = JavascriptCompiler.Compile("sqrt(score)+ln(popularity)", functions);
@lucene.experimental
Fields
Name | Description |
---|---|
DEFAULT_FUNCTIONS | The default set of functions available to expressions. |
Methods
Name | Description |
---|---|
Compile(String) | Compiles the given expression. |
Compile(String, IDictionary<String, MethodInfo>) | Compiles the given expression with the supplied custom functions. |