Error while running script in elastic search , gateway timeout












0















while running script in elastic search, I got 504 Gateway timeout error.



 {
"query": {
"bool": {
"filter": {
"script": {
"script": " doc['creted_date'].date.getMonthOfYear() == 12 "
}
}
}
},
"aggs": {
"test": {
"date_histogram": {
"field": "creted_date",
"interval": "month",
"format": "MMM"

},
"aggs": {
"cost": {
"sum": {
"field": "cost"
}
}
}
}
}
}


Error result :



 {
"statusCode": 504,
"error": "Gateway Time-out",
"message": "Client request timeout"
}


whenever I am running this script over index having small number of documents , it gives perfect output. but on index having large number of documents , it gives above error.



Can we manually set the timeout for request in elastic search ? or Is there any other solution for this problem ?










share|improve this question





























    0















    while running script in elastic search, I got 504 Gateway timeout error.



     {
    "query": {
    "bool": {
    "filter": {
    "script": {
    "script": " doc['creted_date'].date.getMonthOfYear() == 12 "
    }
    }
    }
    },
    "aggs": {
    "test": {
    "date_histogram": {
    "field": "creted_date",
    "interval": "month",
    "format": "MMM"

    },
    "aggs": {
    "cost": {
    "sum": {
    "field": "cost"
    }
    }
    }
    }
    }
    }


    Error result :



     {
    "statusCode": 504,
    "error": "Gateway Time-out",
    "message": "Client request timeout"
    }


    whenever I am running this script over index having small number of documents , it gives perfect output. but on index having large number of documents , it gives above error.



    Can we manually set the timeout for request in elastic search ? or Is there any other solution for this problem ?










    share|improve this question



























      0












      0








      0








      while running script in elastic search, I got 504 Gateway timeout error.



       {
      "query": {
      "bool": {
      "filter": {
      "script": {
      "script": " doc['creted_date'].date.getMonthOfYear() == 12 "
      }
      }
      }
      },
      "aggs": {
      "test": {
      "date_histogram": {
      "field": "creted_date",
      "interval": "month",
      "format": "MMM"

      },
      "aggs": {
      "cost": {
      "sum": {
      "field": "cost"
      }
      }
      }
      }
      }
      }


      Error result :



       {
      "statusCode": 504,
      "error": "Gateway Time-out",
      "message": "Client request timeout"
      }


      whenever I am running this script over index having small number of documents , it gives perfect output. but on index having large number of documents , it gives above error.



      Can we manually set the timeout for request in elastic search ? or Is there any other solution for this problem ?










      share|improve this question
















      while running script in elastic search, I got 504 Gateway timeout error.



       {
      "query": {
      "bool": {
      "filter": {
      "script": {
      "script": " doc['creted_date'].date.getMonthOfYear() == 12 "
      }
      }
      }
      },
      "aggs": {
      "test": {
      "date_histogram": {
      "field": "creted_date",
      "interval": "month",
      "format": "MMM"

      },
      "aggs": {
      "cost": {
      "sum": {
      "field": "cost"
      }
      }
      }
      }
      }
      }


      Error result :



       {
      "statusCode": 504,
      "error": "Gateway Time-out",
      "message": "Client request timeout"
      }


      whenever I am running this script over index having small number of documents , it gives perfect output. but on index having large number of documents , it gives above error.



      Can we manually set the timeout for request in elastic search ? or Is there any other solution for this problem ?







      javascript elasticsearch timeout api-gateway http-status-code-504






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 13 '18 at 13:07







      kavi

















      asked Sep 24 '18 at 10:39









      kavikavi

      5011




      5011
























          2 Answers
          2






          active

          oldest

          votes


















          0














          Try this for Elasticsearch 6.x.



          {
          "query": {
          "bool": {
          "filter": {
          "script": {
          "script": {
          "source": "doc['created_on'].date.getMonthOfYear() == params.month",
          "params": {
          "month": 5
          }
          }
          }
          }
          }
          }
          }





          share|improve this answer
























          • I am not asking for the query. My query is perfectly working for the index having small no of documents. But the problem is timeout. Is there any configuration we need to do in elastic search ?

            – kavi
            Sep 25 '18 at 4:54



















          0














          Try this.



          {
          "query": {
          "bool": {
          "filter": {
          "script": {
          "lang": "expression",
          "script": "doc['creted_date'].getMonth() == month-1",
          "params": {
          "month": 12
          }
          }
          }
          }
          }
          }





          share|improve this answer
























          • not working ."type": "parsing_exception", "reason": "[script] query does not support [lang]"

            – kavi
            Sep 24 '18 at 11:42











          • which Elasticsearch version you are using ?

            – Ashwani Shakya
            Sep 24 '18 at 11:44











          • I am using elastic search 6.0

            – kavi
            Sep 24 '18 at 11:45











          • Ok. try my below answer for elasticsearch 6.x.

            – Ashwani Shakya
            Sep 24 '18 at 15:22











          • Thanks for reply.But there is no mistake in my query. Its perfect. The problem is the timeout for the query request in elastic search. Can we change the timeout ? Yes. then How ?

            – kavi
            Sep 25 '18 at 4:51













          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f52477518%2ferror-while-running-script-in-elastic-search-gateway-timeout%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          Try this for Elasticsearch 6.x.



          {
          "query": {
          "bool": {
          "filter": {
          "script": {
          "script": {
          "source": "doc['created_on'].date.getMonthOfYear() == params.month",
          "params": {
          "month": 5
          }
          }
          }
          }
          }
          }
          }





          share|improve this answer
























          • I am not asking for the query. My query is perfectly working for the index having small no of documents. But the problem is timeout. Is there any configuration we need to do in elastic search ?

            – kavi
            Sep 25 '18 at 4:54
















          0














          Try this for Elasticsearch 6.x.



          {
          "query": {
          "bool": {
          "filter": {
          "script": {
          "script": {
          "source": "doc['created_on'].date.getMonthOfYear() == params.month",
          "params": {
          "month": 5
          }
          }
          }
          }
          }
          }
          }





          share|improve this answer
























          • I am not asking for the query. My query is perfectly working for the index having small no of documents. But the problem is timeout. Is there any configuration we need to do in elastic search ?

            – kavi
            Sep 25 '18 at 4:54














          0












          0








          0







          Try this for Elasticsearch 6.x.



          {
          "query": {
          "bool": {
          "filter": {
          "script": {
          "script": {
          "source": "doc['created_on'].date.getMonthOfYear() == params.month",
          "params": {
          "month": 5
          }
          }
          }
          }
          }
          }
          }





          share|improve this answer













          Try this for Elasticsearch 6.x.



          {
          "query": {
          "bool": {
          "filter": {
          "script": {
          "script": {
          "source": "doc['created_on'].date.getMonthOfYear() == params.month",
          "params": {
          "month": 5
          }
          }
          }
          }
          }
          }
          }






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Sep 24 '18 at 15:23









          Ashwani ShakyaAshwani Shakya

          16619




          16619













          • I am not asking for the query. My query is perfectly working for the index having small no of documents. But the problem is timeout. Is there any configuration we need to do in elastic search ?

            – kavi
            Sep 25 '18 at 4:54



















          • I am not asking for the query. My query is perfectly working for the index having small no of documents. But the problem is timeout. Is there any configuration we need to do in elastic search ?

            – kavi
            Sep 25 '18 at 4:54

















          I am not asking for the query. My query is perfectly working for the index having small no of documents. But the problem is timeout. Is there any configuration we need to do in elastic search ?

          – kavi
          Sep 25 '18 at 4:54





          I am not asking for the query. My query is perfectly working for the index having small no of documents. But the problem is timeout. Is there any configuration we need to do in elastic search ?

          – kavi
          Sep 25 '18 at 4:54













          0














          Try this.



          {
          "query": {
          "bool": {
          "filter": {
          "script": {
          "lang": "expression",
          "script": "doc['creted_date'].getMonth() == month-1",
          "params": {
          "month": 12
          }
          }
          }
          }
          }
          }





          share|improve this answer
























          • not working ."type": "parsing_exception", "reason": "[script] query does not support [lang]"

            – kavi
            Sep 24 '18 at 11:42











          • which Elasticsearch version you are using ?

            – Ashwani Shakya
            Sep 24 '18 at 11:44











          • I am using elastic search 6.0

            – kavi
            Sep 24 '18 at 11:45











          • Ok. try my below answer for elasticsearch 6.x.

            – Ashwani Shakya
            Sep 24 '18 at 15:22











          • Thanks for reply.But there is no mistake in my query. Its perfect. The problem is the timeout for the query request in elastic search. Can we change the timeout ? Yes. then How ?

            – kavi
            Sep 25 '18 at 4:51


















          0














          Try this.



          {
          "query": {
          "bool": {
          "filter": {
          "script": {
          "lang": "expression",
          "script": "doc['creted_date'].getMonth() == month-1",
          "params": {
          "month": 12
          }
          }
          }
          }
          }
          }





          share|improve this answer
























          • not working ."type": "parsing_exception", "reason": "[script] query does not support [lang]"

            – kavi
            Sep 24 '18 at 11:42











          • which Elasticsearch version you are using ?

            – Ashwani Shakya
            Sep 24 '18 at 11:44











          • I am using elastic search 6.0

            – kavi
            Sep 24 '18 at 11:45











          • Ok. try my below answer for elasticsearch 6.x.

            – Ashwani Shakya
            Sep 24 '18 at 15:22











          • Thanks for reply.But there is no mistake in my query. Its perfect. The problem is the timeout for the query request in elastic search. Can we change the timeout ? Yes. then How ?

            – kavi
            Sep 25 '18 at 4:51
















          0












          0








          0







          Try this.



          {
          "query": {
          "bool": {
          "filter": {
          "script": {
          "lang": "expression",
          "script": "doc['creted_date'].getMonth() == month-1",
          "params": {
          "month": 12
          }
          }
          }
          }
          }
          }





          share|improve this answer













          Try this.



          {
          "query": {
          "bool": {
          "filter": {
          "script": {
          "lang": "expression",
          "script": "doc['creted_date'].getMonth() == month-1",
          "params": {
          "month": 12
          }
          }
          }
          }
          }
          }






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Sep 24 '18 at 11:16









          Ashwani ShakyaAshwani Shakya

          16619




          16619













          • not working ."type": "parsing_exception", "reason": "[script] query does not support [lang]"

            – kavi
            Sep 24 '18 at 11:42











          • which Elasticsearch version you are using ?

            – Ashwani Shakya
            Sep 24 '18 at 11:44











          • I am using elastic search 6.0

            – kavi
            Sep 24 '18 at 11:45











          • Ok. try my below answer for elasticsearch 6.x.

            – Ashwani Shakya
            Sep 24 '18 at 15:22











          • Thanks for reply.But there is no mistake in my query. Its perfect. The problem is the timeout for the query request in elastic search. Can we change the timeout ? Yes. then How ?

            – kavi
            Sep 25 '18 at 4:51





















          • not working ."type": "parsing_exception", "reason": "[script] query does not support [lang]"

            – kavi
            Sep 24 '18 at 11:42











          • which Elasticsearch version you are using ?

            – Ashwani Shakya
            Sep 24 '18 at 11:44











          • I am using elastic search 6.0

            – kavi
            Sep 24 '18 at 11:45











          • Ok. try my below answer for elasticsearch 6.x.

            – Ashwani Shakya
            Sep 24 '18 at 15:22











          • Thanks for reply.But there is no mistake in my query. Its perfect. The problem is the timeout for the query request in elastic search. Can we change the timeout ? Yes. then How ?

            – kavi
            Sep 25 '18 at 4:51



















          not working ."type": "parsing_exception", "reason": "[script] query does not support [lang]"

          – kavi
          Sep 24 '18 at 11:42





          not working ."type": "parsing_exception", "reason": "[script] query does not support [lang]"

          – kavi
          Sep 24 '18 at 11:42













          which Elasticsearch version you are using ?

          – Ashwani Shakya
          Sep 24 '18 at 11:44





          which Elasticsearch version you are using ?

          – Ashwani Shakya
          Sep 24 '18 at 11:44













          I am using elastic search 6.0

          – kavi
          Sep 24 '18 at 11:45





          I am using elastic search 6.0

          – kavi
          Sep 24 '18 at 11:45













          Ok. try my below answer for elasticsearch 6.x.

          – Ashwani Shakya
          Sep 24 '18 at 15:22





          Ok. try my below answer for elasticsearch 6.x.

          – Ashwani Shakya
          Sep 24 '18 at 15:22













          Thanks for reply.But there is no mistake in my query. Its perfect. The problem is the timeout for the query request in elastic search. Can we change the timeout ? Yes. then How ?

          – kavi
          Sep 25 '18 at 4:51







          Thanks for reply.But there is no mistake in my query. Its perfect. The problem is the timeout for the query request in elastic search. Can we change the timeout ? Yes. then How ?

          – kavi
          Sep 25 '18 at 4:51




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f52477518%2ferror-while-running-script-in-elastic-search-gateway-timeout%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Florida Star v. B. J. F.

          Retrieve a Users Dashboard in Tumblr with R and TumblR. Oauth Issues