Elastic search Java client ver 2.3.1: How to set size while using setTemplate in searchRequestbuilder


(Deepak Banka) #1

I want to search using a mustache template and set size attribute as 5.

    templateInstance = new Template(
                        searchQueryParamInstance.getTemplateName(),
                        ScriptService.ScriptType.INDEXED,
                        MustacheScriptEngineService.NAME,
                        null,
                        searchQueryParamInstance.getParams()
                );

My search request builder is

SearchRequestBuilder requestBuilder=client.prepareSearch()
                .setIndices((String) entitySearchParams.get(INDEX_NAME))
                .setTypes(entityTypesArray)
                .setFrom(from)
                .setSize(size)
                .setTemplate(templateInstance)
                .setFetchSource(include,exclude);

Print of templateInstance

[script: deterministicAndTemplate, type: id, lang: mustache, params: {param1=attributesInfo.en.xyz.ngram, value1=first second third}]

print of requestBuilder

{
  "from" : 0,
  "size" : 5,
  "_source" : {
    "includes" : [ ],
    "excludes" : [ ]
  }
}

Even though the print of request builder doesn't show anything about the template but the search works fine. But size is not working. I am trying to set the size as 15 but I am always getting 10 results..


(system) #2

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