Different set of results for "significant terms" in Elasticsearch using REST Api or Transportclient

231 Views Asked by At

We use the new significant terms plugin in elasticsearch. Using the transport client I get less results compared to that when I use the REST API. I don't understand why. Using the node client is unfortunately not possible, since my service using ES is not in the same network. Why are the results different?

Here is the REST call:

POST /searchresults_sharded/article/_search 
{
  "query": {
    "match": {
      "titlebody": {
        "query": "japanische hundenamen",
        "operator": "and"
      }
    }
  },
  "aggregations": {
    "searchresults": {
      "significant_terms": {
        "field": "titlebody",
        "size": 100
      }
    }
  }
}

and here the scala request building code:

    val builder = reqBuilder.searchReqBuilder
    builder.setIndices(indexCoords.indexName)
    builder.setTypes(indexCoords.typeName)
    builder.setQuery(QueryBuilders.matchQuery(indexCoords.field, keywords.mkString(" ")).operator(MatchQueryBuilder.Operator.AND))
    val sigTermAggKey: String = "significant-term"
    val sigTermBuilder = new SignificantTermsBuilder(sigTermAggKey)
    sigTermBuilder.field(indexCoords.field)
    sigTermBuilder.size(size)
    builder.addAggregation(sigTermBuilder)
1

There are 1 best solutions below

0
On

I used toString on the Builder and found out: Reason was the different size parameter of the two requests. Both request sizes (20 and 100) were bigger than the returned signif.term-aggregation bucket size (7 compared to 1) but it seems that the query size param has an impact on the returned size even if it's far below the query size parameter