Nest Script Query example


I came across script query topic in Nest

I'm just looking for an example on how to use this. What would be an example _templateString in the above link which is valid?

I tried "ctx._source.UserIds.contains(params.param1)" and it throws a null pointer exception at "ctx". what would be an appropriate example usage.

Note: I'm using ElasticSearch 6.x


If you click on the Edit link next to the documentation example:

It'll take you to the GitHub page for the documentation, and in that page is a comment that links back to the source code from which the documentation was generated e.g. for the above page

This file has been generated from 
If you wish to submit a PR for any spelling mistakes, typos or grammatical errors for this file,
please modify the original csharp file found at the link and submit the PR with that change. Thanks!

In the ScriptQueryUsageTests.cs tests, _templateString is

private static readonly string _templateString = "doc['numberOfCommits'].value > param1";

So you probably want something like

var response = client.Search<Question>(s => s
   .Query(q => q
       .Script(sq => sq
            .Params(p => p
                .Add("param1", "c#")                

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.