Elastic Search - QueryBuilder JAVA

I'm currently working on elasticsearch where I've created a query :

"query": {

    "bool": {
      "must": [
        {"match": {
          "companyId": 35
          "multi_match": {
            "query": "movie",
            "fields": ["name", "description"]

For which I have build QueryBuilder in JAVA :

        SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();

        QueryBuilder mulMatch = QueryBuilders.multiMatchQuery(name,"name", "description").type("phrase").boost(5);
        QueryBuilder cId = QueryBuilders.matchQuery("companyId", companyId).boost(5);
        QueryBuilder must = QueryBuilders.boolQuery().must(cId).must(mulMatch).boost(5);
        System.out.println("SS Query : " + searchSourceBuilder);

which gives me query created as :


However, I require output such as :


          "Id": 1,
          "name": "Controle",
          "description": "Welcome movie",
          "visibility": "2",
          "isarticleEnabled": false,
          "companyId": 35,
          "categoryId": 0        

So to get such a a response, what should I exactly do? What do I need to write in queryBuilder to get the required output?

Note: I've searched for all the relative solutions, i.e. Search Request, Search Response, but I was unable to get any of the proper solutions.

Hi @Parva_Gurav

The query not works?

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