You are looking at documentation for an older release.
Not what you want? See the
current release documentation.
Script Fields Usageedit
Fluent DSL Exampleedit
s => s .ScriptFields(sf=>sf .ScriptField("test1", sc=>sc .Inline("doc['my_field_name'].value * 2") ) .ScriptField("test2", sc=>sc .Inline("doc['my_field_name'].value * factor") .Params(p=>p .Add("factor", 2.0) ) ) )
Object Initializer Syntax Exampleedit
new SearchRequest<Project> { ScriptFields = new ScriptFields { { "test1", new ScriptField { Script = new InlineScript("doc['my_field_name'].value * 2") } }, { "test2", new InlineScript("doc['my_field_name'].value * factor") { Params = new FluentDictionary<string, object> { { "factor", 2.0 } } } } } }
Example json output.
{ "script_fields": { "test1": { "script": { "inline": "doc['my_field_name'].value * 2" } }, "test2": { "script": { "inline": "doc['my_field_name'].value * factor", "params": { "factor": 2.0 } } } } }