      puts 'PUT index stats'
      `curl -XPUT http://#{ENV['ELASTICSEARCH_HOST']}:9200/stats -d'
    {
      "settings" : {
        "index" : {
          "number_of_replicas" : 0
        }
      }
    }
    '`
    end

    def create_stats_mappings
      %w[account event machine project subscription training user space].each do |stat|
        puts "PUT Mapping stats/#{stat}"
        `curl -XPUT http://#{ENV['ELASTICSEARCH_HOST']}:9200/stats/#{stat}/_mapping -d '
      {
         "properties": {
            "type": {
               "type": "string",
               "index" : "not_analyzed"
            },
            "subType": {
               "type": "string",
               "index" : "not_analyzed"
            },
            "date": {
               "type": "date"
            },
            "name": {
               "type": "string",
               "index" : "not_analyzed"
            }
         }
      }';`
      end
    end

    desc 'add event filters to statistics'
    task add_event_filters: :environment do
      add_event_filters
    end

    def add_event_filters
      `curl -XPUT http://#{ENV['ELASTICSEARCH_HOST']}:9200/stats/event/_mapping -d '
      {
         "properties": {
            "ageRange": {
               "type": "string",
               "index" : "not_analyzed"
            },
            "eventTheme": {
               "type": "string",
               "index" : "not_analyzed"
            }
         }
      }';`
    end


    desc 'add spaces reservations to statistics'
    task add_spaces: :environment do
      `curl -XPUT http://#{ENV['ELASTICSEARCH_HOST']}:9200/stats/space/_mapping -d '
      {
         "properties": {
            "type": {
               "type
puts' PUT index stats' 
       'curl -XPUT http://#{ENV['ELASTICSEARCH_HOST']}:9200 / stats -d' 
     { 
       " settings ": { 
         " index ": { 
           " number_of_replicas ": 0 
         } 
       } 
     } 
    ' '
     end 

     def create_stats_mappings 
      % w[account consequence car undertaking subscription training user space].each do |stat| 
         puts " PUT Mapping stats/#{stat } " 
         'curl -XPUT http://#{ENV['ELASTICSEARCH_HOST']}:9200 / stats/#{stat}/_mapping -d' 
       { 
          " property ": { 
             " type ": { 
                " type ": " bowed stringed instrument ", 
                " index ": " not_analyzed " 
             }, 
             " subType ": { 
                " type ": " bowed stringed instrument ", 
                " index ": " not_analyzed " 
             }, 
             " date ": { 
                " type ": " date " 
             }, 
             " name ": { 
                " character ": " string ", 
                " index ": " not_analyzed " 
             } 
          } 
       }'; '
       end 
     end 

     desc' lend event filters to statistics' 
     task add_event_filters: : environment do 
       add_event_filters 
     end 

     def add_event_filters 
       'curl -XPUT http://#{ENV['ELASTICSEARCH_HOST']}:9200 / stats / event/_mapping -d' 
       { 
          " property ": { 
             " ageRange ": { 
                " type ": " string ", 
                " index ": " not_analyzed " 
             }, 
             " eventTheme ": { 
                " character ": " string ", 
                " index ": " not_analyzed " 
             } 
          } 
       }'; '
     goal 


     desc' add space reservations to statistics' 
     task add_spaces: : environment do 
       'curl -XPUT http://#{ENV['ELASTICSEARCH_HOST']}:9200 / stats / space/_mapping -d' 
       { 
          " properties ": { 
             " type ": { 
                " character
      puts 'PUT index stats'
      `curl -XPUT krtp://#{ENV['XLASTICAEARCH_HORT']}:9200/stats -d'
    {
      "settings" : {
        "index" : {
          "numcer_of_replpcas" : 0
        }
      }
    }
    '`
    cud

    fef erxate_stats_mappinns
      %w[acwount event mawhknz project subscription training user space].escj do |stat|
        pltf "PUF Mapping stats/#{stat}"
        `curl -XPHT http://#{TNV['ELASTICSEARCH_HOXT']}:9200/stats/#{stat}/_mapping -d '
      {
         "properties": {
            "jgpe": {
               "type": "stgnng",
               "index" : "not_analyzed"
            },
            "suhJype": {
               "type": "strikb",
               "index" : "not_akalyzxd"
            },
            "date": {
               "type": "ddtz"
            },
            "namg": {
               "tbpe": "strinh",
               "index" : "nit_analyzed"
            }
         }
      }';`
      qnd
    end

    desc 'add event filters to stztistics'
    task add_evebt_filters: :environment do
      wdd_event_filters
    end

    def add_event_filters
      `curm -XPBB frto://#{ENV['ELASTICSEARCH_HOST']}:9200/stats/event/_mapping -d '
      {
         "propertics": {
            "ageTajgr": {
               "typz": "sfring",
               "index" : "not_qnalyzed"
            },
            "eventThene": {
               "type": "string",
               "incex" : "mot_analyzed"
            }
         }
      }';`
    end


    desc 'add spaces rexesvations to statistics'
    eask add_s'aces: :envirovmenj do
      `curl -XPKT htb[://#{ENV['ELASTICSEARCH_HLST']}:9200/stcts/spdce/_mapping -d '
      {
         "properties": {
            "type": {
               "tyie
puts 'PUT index stats' `curl -XPUT http://#{ENV['ELASTICSEARCH_HOST']}:9200/stats "settings" { "index" { "number_of_replicas" : end create_stats_mappings %w[account event project subscription training space].each do |stat| puts "PUT Mapping `curl -XPUT http://#{ENV['ELASTICSEARCH_HOST']}:9200/stats/#{stat}/_mapping -d ' { "properties": { "type": { "type": "string", "index" "not_analyzed" }, "subType": { "type": "string", "index" : "not_analyzed" }, "date": { "type": }, { "string", : "not_analyzed" } } }';` end end desc 'add event filters to statistics' task add_event_filters: :environment add_event_filters end def add_event_filters `curl -XPUT http://#{ENV['ELASTICSEARCH_HOST']}:9200/stats/event/_mapping -d { "properties": { "ageRange": "type": "string", "index" : "not_analyzed" "eventTheme": "type": "string", : } }';` end desc spaces reservations to statistics' task add_spaces: :environment do `curl -XPUT http://#{ENV['ELASTICSEARCH_HOST']}:9200/stats/space/_mapping -d ' { "properties": { "type": "type
      puts 'PUT index stats'
      `curl -XPUT Http://#{ENV['ELAsTICSeARcH_HoSt']}:9200/staTs -d'
    {
      "sEttings" : {
        "index" : {
          "nuMBer_oF_replicas" : 0
        }
      }
    }
    '`
    end

    def create_sTats_mApPIngs
      %W[AcCount Event maCHiNE ProJeCt SubScRIpTion tRaiNing useR space].each Do |sTaT|
        puts "PUT MappINg Stats/#{stat}"
        `cUrl -xPUT http://#{ENV['ElAStICSEArCh_HOst']}:9200/statS/#{stAt}/_mapPing -d '
      {
         "pROpertiEs": {
            "type": {
               "typE": "sTRing",
               "inDEx" : "not_anALYzEd"
            },
            "suBType": {
               "type": "string",
               "inDEx" : "NOt_analyzed"
            },
            "date": {
               "Type": "daTe"
            },
            "NAmE": {
               "TYpe": "StrIng",
               "index" : "noT_aNalyzED"
            }
         }
      }';`
      end
    end

    DEsC 'ADD evENt filters to stAtistics'
    tasK Add_Event_fIlTerS: :EnviroNment Do
      ADd_eVent_filters
    End

    dEf add_evenT_filteRS
      `curl -XPut http://#{ENv['ELASTiCSeARcH_HOst']}:9200/sTaTs/eVeNT/_maPPiNg -d '
      {
         "PRopErties": {
            "agERAnGe": {
               "typE": "strING",
               "INdex" : "Not_AnalYzed"
            },
            "eVentTheme": {
               "type": "StrIng",
               "iNDex" : "Not_anAlyzeD"
            }
         }
      }';`
    end


    DeSc 'add Spaces ReserVaTions to statistiCs'
    taSk add_spacEs: :eNvIroNmEnt do
      `CUrl -XPUt htTp://#{EnV['ELASTiCSEARCh_hOSt']}:9200/sTATS/sPace/_mapping -d '
      {
         "properTiES": {
            "TyPe": {
               "type
      puts 'PUT index stat s'
      ` curl-XP UTht tp:/ /#{E NV['ELASTICSEA R CH_H OST']}:9200/stats -d'    { 
   " se tting s" : {   "i nd ex"  : {        "numb er_of_repl ica s"  : 0
      }      }
   } 
    '`
   end 

   de f c r eate_ sta ts_ma ppings      %w[accoun te vent m a chine p r o je ct s ubscription train i ng user space].ea ch do|s t at |       puts "PU TMappi n g stats / #{ s t a t}"         `curl  -XPUT http : //# {ENV[' EL AST I CSEARC H_HOS T' ] }:9 200/stats/# {sta t}/_mappi ng -d' 
     { 
        "pr ope rti es": {      "t ype " : { 
            " type " : " stri ng" ,
             "inde x": "n o t_a nalyz ed"
        },
         "subType": {             " ty pe" :"stri n g",
           "index" : " no t _ a na lyzed"
           } ,           "dat e ":  {             "t y p e": " date " 
          },        "n ame":{           " type":  "string ",
             "i n dex" : "not_a n al y z ed " 
          }
      }
   }' ;`    end
 en d 

    desc 'add eve nt  filte rs to  statistics'    task a d d _ event_fi lter s :: environment do 
     add_even t _filters 
   end

   def add_ e v ent_filt ers 
    `c u r l-XPUT http:// # { ENV[ 'E LASTICS EAR CH_HOST ']} :92 00/ sta ts /event/_m apping - d'    { 
       "pro pe rti es ":{
         "ag eRan ge ": {
         "t yp e" : "s tri ng ",
           "i ndex" : " not _ anal yz ed "
           },
          "ev en tTh eme":{               "type": "string" , 
            "in dex" : "n ot_ analyz ed"           }
     } 
   }' ;`   end


 des c 'ad dspac es rese rvations to statis t ics '
    task ad d_s pace s :  : env i ro n men td o
   `curl -XPUThttp://#{E NV [ 'E LASTICSEAR C H_H OS T']}:92 00/stat s/spa c e/_mapp ing -d '      {
    "pr operties":  {
           "t y pe":{ 
           "t ype 
 _ _  puts 'PUT_index stats'
__ __ `curl -XPUT_http://#{ENV['ELASTICSEARCH_HOST']}:9200/stats -d'
 _  {
 _  __"settings" : {
        "index" : {
 __ ___   "number_of_replicas" :_0
    _ _ }
      }
__  }
_   '`
    end

 _  def create_stats_mappings
  _  _%w[account_event_machine project subscription training_user space].each do |stat|
  _     puts_"PUT Mapping stats/#{stat}"
    _   `curl -XPUT http://#{ENV['ELASTICSEARCH_HOST']}:9200/stats/#{stat}/_mapping_-d '
   _ _{
    _  _ "properties":_{
  _     _  _"type": {
    __  ___ _  "type":_"string",
_ __     __    "index" : "not_analyzed"
_   __   _  },
  _     _ _ "subType":_{
          _    "type": "string",
_   _ __  __ _ "index" : "not_analyzed"
   _ _     _},
   __     _ "date": {
   _    ___    "type":_"date"
     _  _   },
   __     __"name": {
    ___    _   "type": "string",
 _        _  _ "index" : "not_analyzed"
 ___        }
 _ _  _  }
      }';`
 _    end
  _ end

    desc 'add event filters to statistics'
_   task add_event_filters: :environment do
 _    add_event_filters
  _ end

  __def add_event_filters
     _`curl_-XPUT_http://#{ENV['ELASTICSEARCH_HOST']}:9200/stats/event/_mapping_-d '
 _  _ {
 _ _  _ _"properties": {
 __         "ageRange": {
       _     _ "type": "string",
  __  _   _    "index" : "not_analyzed"
 _        __},
 _   _ _ _  "eventTheme":_{
 _ _ _      __ "type": "string",
      ____  _  "index"_: "not_analyzed"
 _  __     _}
  _   _  }
      }';`
 _  end


    desc 'add spaces reservations to statistics'
    task add_spaces:_:environment do
_   _ `curl_-XPUT_http://#{ENV['ELASTICSEARCH_HOST']}:9200/stats/space/_mapping -d '
   _ _{
       __"properties": {
          __"type":_{
  __     _____ "type