web/apps/hello-elasticsearch/js/hello-elasticsearch.js
function handleQuery() {
  let query = parseQuery();
  let url = window.location.protocol + '//' + window.location.hostname + ':' +
            window.location.port + ELASTICSEARCH_INTERFACE_ROUTE;
  let httpRequest = new XMLHttpRequest();

  httpRequest.onreadystatechange = function() {
    if(httpRequest.readyState === XMLHttpRequest.DONE) {
      if(httpRequest.status === 200) {
        let response = JSON.parse(httpRequest.responseText);
        updateResults(response);
        updateHits(response);
        updateAggregations(response);
        show(queryResults);
      }
      else {
        queryError.textContent = 'Query returned status ' +
                                 httpRequest.status +
                                 '. Is Elasticsearch connected and running?';
        hide(queryResults);
        hide(queryButton);
        show(queryError);
      }
    }
  };
  httpRequest.open('POST', url);
  httpRequest.setRequestHeader('Content-Type', 'application/json');
  httpRequest.setRequestHeader('Accept', 'application/json');
  httpRequest.send(JSON.stringify(query));
}
function handleQuery() {
  let query = parseQuery();
  let url = window.location.protocol + '//' + window.location.hostname + ':' +
            window.location.port + ELASTICSEARCH_INTERFACE_ROUTE;
  let httpRequest = new XMLHttpRequest();

  httpRequest.onreadystatechange = function() {
    if(httpRequest.readyState === XMLHttpRequest.DONE) {
      if(httpRequest.status === 200) {
        let response = JSON.parse(httpRequest.responseText);
        updateResults(response);
        updateHits(response);
        updateAggregations(response);
        show(queryResults);
      }
      else {
        queryError.textContent = 'Query returned status ' +
                                 httpRequest.status +
                                 '. Is Elasticsearch connected and running?';
        hide(queryResults);
        hide(queryButton);
        show(queryError);
      }
    }
  };
  httpRequest.open('POST', url);
  httpRequest.setRequestHeader('Content-Type', 'application/json');
  httpRequest.setRequestHeader('Accept', 'application/json');
  httpRequest.send(JSON.stringify(query));
}
function handleQuery ( ) { let query = parseQuery ( ) ; let url = window . location . protocol + '//' + window . location . hostname + ':' + window . location . port + ELASTICSEARCH_INTERFACE_ROUTE ; let httpRequest = new XMLHttpRequest ( ) ; httpRequest . onreadystatechange = function ( ) { if ( httpRequest . readyState === XMLHttpRequest . DONE ) { if ( httpRequest . status === 200 ) { let response = JSON . parse ( httpRequest . responseText ) ; updateResults ( response ) ; updateHits ( response ) ; updateAggregations ( response ) ; show ( queryResults ) ; } else { queryError . textContent = 'Query returned status ' + httpRequest . status + '. Is Elasticsearch connected and running?' ; hide ( queryResults ) ; hide ( queryButton ) ; show ( queryError ) ; } } } ; httpRequest . open ( 'POST' , url ) ; httpRequest . setRequestHeader ( 'Content-Type' , 'application/json' ) ; httpRequest . setRequestHeader ( 'Accept' , 'application/json' ) ; httpRequest . send ( JSON . stringify ( query ) ) ; }
Handle the current Elasticsearch query
Handle the current Elasticsearch query