<commit_before>import { Meteor } from 'meteor/meteor';

import { esClient } from '/server/elasticsearch';

import async from 'async';

import _ from 'lodash';

Meteor.methods({
  getElasticSearchData (params) {

    let opts = {
      index: params.index,
      type: params.type,
      size: params.size,
      body: {
        query: params.query
      }
    };

    if (params.fields && params.fields.length != 0) {
      opts.body.fields = params.fields;
    }

    const start = new Date().getTime();

    return esClient.search(opts).then((res) => {

      console.log((new Date().getTime() - start) / 1000 );

      return res;
    });
  },
  async syncElasticSearchData () {

    let syncComplete = false;
    let fromItem = 0;
    let size = 10000;

    console.log('Sync started.');

    while (syncComplete === false) {

      const params = {
        index: 'api-umbrella-logs-v1-2016-06',
        type: 'log',
        from: fromItem,
        size: size,
        query: {
          match_all: {}
        }<commit_msg>Add sorting<commit_after>import { Meteor } from 'meteor/meteor';

import { esClient } from '/server/elasticsearch';

import async from 'async';

import _ from 'lodash';

Meteor.methods({
  getElasticSearchData (params) {

    let opts = {
      index: params.index,
      type: params.type,
      size: params.size,
      body: {
        query: params.query
      }
    };

    if (params.fields && params.fields.length != 0) {
      opts.body.fields = params.fields;
    }

    if (params.sort && params.fields.sort != 0) {
      opts.body.sort = params.sort;
    }

    const start = new Date().getTime();

    return esClient.search(opts).then((res) => {

      console.log((new Date().getTime() - start) / 1000 );

      return res;
    });
  },
  async syncElasticSearchData () {

    let syncComplete = false;
    let fromItem = 0;
    let size = 10000;

    console.log('Sync started.');

    while (syncComplete === false) {

      const params = {
        index: 'api-umbrella-logs-v1-2016-06',
        type: 'log',
        from: fromItem,
        size: size,
        query: {
          match_all: {}
        }
{'fraction_non_alphanumeric': 0.1425244527247322, 'fraction_numerical': 0.017233348858872847, 'mean_word_length': 2.131195335276968, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '303650', 'n_tokens_mistral': 733, 'n_tokens_neox': 672, 'n_words': 157}