Skip to content

Instantly share code, notes, and snippets.

@rafaltrojanowski
Last active January 12, 2022 12:56
Show Gist options
  • Save rafaltrojanowski/1e678dcf39a1591c3b407cc091cd687b to your computer and use it in GitHub Desktop.
Save rafaltrojanowski/1e678dcf39a1591c3b407cc091cd687b to your computer and use it in GitHub Desktop.
indexing issue
Bastion:
a1 = Domain.Repo.get_by(Domain.Answer, id: 555)
query = %{"query" => %{"terms" => %{"_id" => [a1.id]}}}
query |> Domain.Elasticsearch.search("answers_dev5")
{:ok,
%{
"_shards" => %{
"failed" => 0,
"skipped" => 0,
"successful" => 1,
"total" => 1
},
"hits" => %{
"hits" => [
%{
"_id" => "555",
"_index" => "answers_dev5",
"_score" => 1.0,
"_source" => %{
"additional_answers" => [],
"comment" => "Karton wurde vom Paketdienst sicher geworfen.",
"comment_de_DE" => "Karton wurde vom Paketdienst sicher geworfen.",
"has_comment" => true,
"id" => 555,
"inserted_at" => "2021-06-08T09:31:32Z",
"is_a_test" => false,
"label_ids" => [9500],
"language" => "de_DE",
"language_id" => 75,
"properties" => [],
"public_hash_id" => "TXpZeFlUZGlaVFV0T1RRME5TMDBNV1EwTFRnNVpHWXRNakE1WWpGaE1USXlZV1Zr",
"recipient_full_name" => nil,
"recipient_id" => nil,
"recipient_identity" => nil,
"recipient_identity_type" => nil,
"recipient_upload_method" => nil,
"score" => 9,
"score_type" => "promoter",
"sentiment" => "positive",
"sentiment_per_label" => [],
"stripped_comment" => "Karton wurd Paketdien sich geworf",
"survey_id" => 12,
"survey_recipient_id" => nil,
"translated_comment" => nil,
"translated_language_id" => nil,
"updated_at" => "2021-11-26T10:28:13Z"
},
"_type" => "_doc"
}
],
"max_score" => 1.0,
"total" => %{"relation" => "eq", "value" => 1}
},
"timed_out" => false,
"took" => 1
}}
@rafaltrojanowski
Copy link
Author

Dev 2 steps:

https://github.com/zenloopGmbH/documentation/blob/master/docs/how_to/elasticsearch.md

template = {
  "settings": {
    "number_of_replicas": 1,
    "number_of_shards": 1,
    "refresh_interval": "1s",
    "analysis": {
      "analyzer": {
        "lowercase_analyzer": {
          "tokenizer": "lowercase"
        },
        "email_analyzer": {
          "tokenizer": "uax_url_email"
        }
      }
    }
  },
  "mappings": {
    "properties": {
      "id": {
        "type": "integer"
      },
      "score": {
        "type": "byte",
        "null_value": 0
      },
      "stripped_comment": {
        "type": "text",
        "analyzer": "standard"
      },
      "comment": {
        "type": "text",
        "analyzer": "standard",
        "search_analyzer": "standard",
        "term_vector": "with_positions_offsets"
      },
      "comment_ar_AE": {
        "analyzer": "arabic",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_bg_BG": {
        "analyzer": "bulgarian",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_bn_BD": {
        "analyzer": "bengali",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_ca_ES": {
        "analyzer": "catalan",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_cs_CZ": {
        "analyzer": "czech",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_da_DK": {
        "analyzer": "danish",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_de_DE": {
        "analyzer": "german",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_el_GR": {
        "analyzer": "greek",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_en_US": {
        "analyzer": "english",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_es_AR": {
        "analyzer": "spanish",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_es_ES": {
        "analyzer": "spanish",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_eu_ES": {
        "analyzer": "basque",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_fr_FR": {
        "analyzer": "french",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_ga_IE": {
        "analyzer": "irish",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_gl_ES": {
        "analyzer": "galician",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_hi_IN": {
        "analyzer": "hindi",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_hr_HR": {
        "analyzer": "standard",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_hu_HU": {
        "analyzer": "hungarian",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_hy_AM": {
        "analyzer": "armenian",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_id_ID": {
        "analyzer": "indonesian",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_it_IT": {
        "analyzer": "italian",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_ja_JP": {
        "analyzer": "kuromoji",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_ko_KR": {
        "analyzer": "nori",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_lt_LT": {
        "analyzer": "lithuanian",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_lv_LV": {
        "analyzer": "latvian",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_ms_MY": {
        "analyzer": "standard",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_nl_NL": {
        "analyzer": "dutch",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_pl_PL": {
        "analyzer": "polish",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_pt_BR": {
        "analyzer": "brazilian",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_pt_PT": {
        "analyzer": "portuguese",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_ro_RO": {
        "analyzer": "romanian",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_ru_RU": {
        "analyzer": "russian",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_sk_SK": {
        "analyzer": "standard",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_sv_SE": {
        "analyzer": "swedish",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_th_TH": {
        "analyzer": "thai",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_tr_TR": {
        "analyzer": "turkish",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_uk_UA": {
        "analyzer": "ukrainian",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_vi_VN": {
        "analyzer": "standard",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_zh_Hans": {
        "analyzer": "smartcn",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_af_ZA": {
        "analyzer": "standard",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_sq_AL": {
        "analyzer": "standard",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_am_ET": {
        "analyzer": "standard",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_az_AZ": {
        "analyzer": "standard",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_be_BY": {
        "analyzer": "standard",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_bs_BA": {
        "analyzer": "standard",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_ceb_PH": {
        "analyzer": "standard",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_co_FR": {
        "analyzer": "standard",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_eo_EO": {
        "analyzer": "standard",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_et_EE": {
        "analyzer": "standard",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_fy_NL": {
        "analyzer": "standard",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_ka_GE": {
        "analyzer": "standard",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_gu_IN": {
        "analyzer": "standard",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_ht_HT": {
        "analyzer": "standard",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_ha_GH": {
        "analyzer": "standard",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_haw_US": {
        "analyzer": "standard",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_he_IL": {
        "analyzer": "standard",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_hmn_HMN": {
        "analyzer": "standard",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_is_IS": {
        "analyzer": "standard",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_ig_NG": {
        "analyzer": "standard",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_jv_ID": {
        "analyzer": "standard",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_kn_IN": {
        "analyzer": "standard",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_kk_KZ": {
        "analyzer": "standard",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_km_KH": {
        "analyzer": "standard",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_ku_IQ": {
        "analyzer": "standard",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_ky_KG": {
        "analyzer": "standard",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_lo_LA": {
        "analyzer": "standard",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_la_LA": {
        "analyzer": "standard",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_lb_LU": {
        "analyzer": "standard",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_mk_MK": {
        "analyzer": "standard",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_ma_MG": {
        "analyzer": "standard",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_mg_MG": {
        "analyzer": "standard",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_ml_IN": {
        "analyzer": "standard",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_mt_MT": {
        "analyzer": "standard",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_mi_MI": {
        "analyzer": "standard",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_mr_IN": {
        "analyzer": "standard",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_mn_MN": {
        "analyzer": "standard",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_ne_NP": {
        "analyzer": "standard",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_ny_ZW": {
        "analyzer": "standard",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_ps_AR": {
        "analyzer": "standard",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_pa_IN": {
        "analyzer": "standard",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_sm_SM": {
        "analyzer": "standard",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_gd_GB": {
        "analyzer": "standard",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_sr_SR": {
        "analyzer": "standard",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_sn_ZW": {
        "analyzer": "standard",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_si_LK": {
        "analyzer": "standard",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_sd_IN": {
        "analyzer": "standard",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_sl_SI": {
        "analyzer": "standard",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_so_SO": {
        "analyzer": "standard",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_su_ID": {
        "analyzer": "standard",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_sw_KE": {
        "analyzer": "standard",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_tl_PH": {
        "analyzer": "standard",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_tg_TJ": {
        "analyzer": "standard",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_ta_IN": {
        "analyzer": "standard",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_te_IN": {
        "analyzer": "standard",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_ur_PK": {
        "analyzer": "standard",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_uz_AF": {
        "analyzer": "standard",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_cy_GB": {
        "analyzer": "standard",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_xh_ZA": {
        "analyzer": "standard",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_yi": {
        "analyzer": "standard",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_yo_NG": {
        "analyzer": "standard",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "comment_zu_ZA": {
        "analyzer": "standard",
        "search_analyzer": "lowercase_analyzer",
        "term_vector": "with_positions_offsets",
        "type": "text"
      },
      "translated_comment": {
        "type": "text",
        "analyzer": "standard"
      },
      "score_type": {
        "type": "keyword",
        "null_value": "detractor"
      },
      "has_comment": {
        "type": "boolean",
        "null_value": false
      },
      "public_hash_id": {
        "type": "keyword"
      },
      "properties": {
        "type": "nested",
        "properties": {
          "id": {
            "type": "integer"
          },
          "name": {
            "type": "keyword"
          },
          "value": {
            "type": "keyword"
          }
        }
      },
      "label_ids": {
        "type": "keyword"
      },
      "label_ids_with_keywords": {
        "type": "flattened"
      },
      "recipient_id": {
        "type": "integer"
      },
      "recipient_full_name": {
        "type": "text"
      },
      "recipient_identity": {
        "type": "text",
        "analyzer": "standard",
        "search_analyzer": "lowercase_analyzer",
        "fields": {
          "email": {
            "type": "text",
            "analyzer": "email_analyzer",
            "search_analyzer": "email_analyzer"
          }
        }
      },
      "recipient_identity_type": {
        "type": "keyword"
      },
      "recipient_upload_method": {
        "type": "keyword"
      },
      "sentiment": {
        "type": "keyword"
      },
      "sentiment_per_label": {
        "type": "nested",
        "properties": {
          "id": {
            "type": "integer"
          },
          "name": {
            "type": "keyword"
          },
          "sentiment": {
            "type": "keyword"
          }
        }
      },
      "survey_id": {
        "type": "integer"
      },
      "survey_recipient_id": {
        "type": "integer"
      },
      "language": {
        "type": "keyword"
      },
      "language_id": {
        "type": "integer"
      },
      "translated_language_id": {
        "type": "integer"
      },
      "inserted_at": {
        "type": "date"
      },
      "updated_at": {
        "type": "date"
      },
      "additional_answers": {
        "type": "nested",
        "properties": {
          "id": {
            "type": "text"
          },
          "additional_question_id": {
            "type": "integer"
          },
          "additional_question_public_hash_id": {
            "type": "keyword"
          },
          "answer": {
            "type": "keyword"
          },
          "inserted_at": {
            "type": "date"
          },
          "position": {
            "type": "integer"
          },
          "question": {
            "type": "text"
          },
          "score_system_id": {
            "type": "integer"
          },
          "has_answer": {
            "type": "boolean"
          }
        }
      }
    }
  }
}



body = {
  "index_patterns": [
    "answers",
    "answers*"
  ],
  "template": {}
}
{:ok, response} = Domain.Env.get(:elasticsearch_url) |> URI.merge("/_index_template/answers_template/_mapping?pretty") |> URI.to_string() |> Elastix.HTTP.put()

@rafaltrojanowski
Copy link
Author

rafaltrojanowski commented Jan 11, 2022

Get all indexes:

{:ok, response} = Domain.Env.get(:elasticsearch_url) |> URI.merge("_cat/indices/answers*?v=true&s=index") |> URI.to_string() |> Elastix.HTTP.get()
iex(api@10.4.5.209)95> response.body
"health status index                     uuid                   pri rep docs.count docs.deleted store.size pri.store.size\ngreen  open   answers                   il41UIeMTKWWdTh1hwDC3g   1   1          5            0     21.6kb         10.8kb\ngreen  open   answers_dev1_v3           WP9W_71ERCCGN4UJgOV70Q   1   1     454111       187717    163.8mb   91.8mb\ngreen  open   answers_dev2_v3           kF81UqRMQxG5hqr8KOQMPw   1   1     485951       168523      190mb         93.2mb\ngreen  open   answers_dev3_v1           Rp1aWK1rSOGkiYQKfC5Vyw   1   1     298611        21583     85.1mb           41mb\ngreen  open   answers_dev4              S0COsGlaSkSWbdgQnkQpww   1   1       2671            3      1.4mb        727.4kb\ngreen  open   answers_dev5              PIh2r9LaTf2GW-Y5ttwlNw   1   1      38711          452     38.7mb         17.9mb\ngreen  open   answers_dev6_v1     9ACUvkTrQOGy8dcIpy19GA   1   1         49            0     84.3kb         42.1kb\ngreen  open   answers_org_pentest_35    pY4rlX7YTOmeaVYGmDRAAQ   1   1          3  0     40.5kb         20.2kb\ngreen  open   answers_org_staging_35222 azajr74xSd-zd8yDktCn1g   1   1          0            0       416b           208b\ngreen  open   answers_org_staging_35_v3 Fk9Wff0sTIar_1RsPAhcQA   1   1      18079         1448      5.8mb          2.9mb\ngreen  open   answers_org_staging_6330  yZ0ikkhTQ5mKQSKq_1MsFQ   1   1         16            0     68.4kb         34.2kb\ngreen  open   answers_org_staging_6583  4T8JiwxPR2qLGczl5IFvWw   1   1          0            0       462b           231b\ngreen  open   answers_org_staging_6587  r746EmINRJCVU8U3_WSHZQ   1   1         34            0     84.7kb         42.3kb\ngreen  open   answers_org_staging_6639  3FrWb7PuSgWMRJQ0nkX2zQ   1   1        15            0     84.5kb         42.2kb\ngreen  open   answers_org_staging_7794  y8oaeJ2KQtK2VH_z9ltKMQ   1   1          7            0       58kb           29kb\ngreen  open   answers_pentest           UlrWKsyySvG9eMfhrBh6kg   1   1     304276        75292    102.8mb         50.2mb\ngreen  open   answers_qa_perf_v1        mtPP4u00QNCYzYEw5hU5Vw   1   1       2423            0    742.2kb        371.1kb\ngreen  open   answers_staging_v2        xFbkM-PESrCt0LlHnIIiKg   1   1   11030606       889771      2.1gb1gb\ngreen  open   answers_staging_v3        t86StB2zTyKt6YoczQkgzg   1   1   11929362      3589651      2.9gb          1.5gb\n"

@rafaltrojanowski
Copy link
Author

From staging:

iex(api@10.2.5.218)2> response.body
"health status index                     uuid                   pri rep docs.count docs.deleted store.size pri.store.size\ngreen  open   answers                   il41UIeMTKWWdTh1hwDC3g  1   1          5            0     21.6kb         10.8kb\ngreen  open   answers_dev1_v3           WP9W_71ERCCGN4UJgOV70Q   1   1     454111       187717    163.8mb         91.8mb\ngreen  open   answers_dev2_v3           kF81UqRMQxG5hqr8KOQMPw   1   1     485951       168523      190mb         93.2mb\ngreen  open   answers_dev3_v1           Rp1aWK1rSOGkiYQKfC5Vyw   11     298611        21583     85.1mb           41mb\ngreen  open   answers_dev4              S0COsGlaSkSWbdgQnkQpww   1   1       2671            3      1.4mb        727.4kb\ngreen  open   answers_dev5              PIh2r9LaTf2GW-Y5ttwlNw   1   1      38720          471       43mb         18.6mb\ngreen  open   answers_dev6_v1           9ACUvkTrQOGy8dcIpy19GA   1   1    49            0     84.3kb         42.1kb\ngreen  open   answers_org_pentest_35    pY4rlX7YTOmeaVYGmDRAAQ   1   1          3            0     40.5kb         20.2kb\ngreen  open   answers_org_staging_35222 azajr74xSd-zd8yDktCn1g   1   1          0            0       416b           208b\ngreen  open   answers_org_staging_35_v3 Fk9Wff0sTIar_1RsPAhcQA   1   1      18079         1448      5.8mb          2.9mb\ngreen  open   answers_org_staging_6330  yZ0ikkhTQ5mKQSKq_1MsFQ   1   1         16            0     68.4kb         34.2kb\ngreen  open   answers_org_staging_6583  4T8JiwxPR2qLGczl5IFvWw   1   1          0            0       462b           231b\ngreen  open   answers_org_staging_6587  r746EmINRJCVU8U3_WSHZQ   1   1         34      0     84.7kb         42.3kb\ngreen  open   answers_org_staging_6639  3FrWb7PuSgWMRJQ0nkX2zQ   1   1         15            0     84.5kb         42.2kb\ngreen  open   answers_org_staging_7794  y8oaeJ2KQtK2VH_z9ltKMQ   1   1          7            0       58kb           29kb\ngreen  open   answers_pentest           UlrWKsyySvG9eMfhrBh6kg   1   1     304276        75292    102.8mb         50.2mb\ngreen  open   answers_qa_perf_v1        mtPP4u00QNCYzYEw5hU5Vw   1   1       2423            0    742.2kb        371.1kb\ngreen  open   answers_staging_v2     xFbkM-PESrCt0LlHnIIiKg   1   1   11030606       889771      2.1gb            1gb\ngreen  open   answers_staging_v3        t86StB2zTyKt6YoczQkgzg   1   1   11929372      3589559 2.9gb          1.5gb\n"

@rafaltrojanowski
Copy link
Author

Problems:

  • Uglu formating of responses
  • Problems with copy pastying long json body
  • Solution Kibana, but yes I prefer to use hammer!

@rafaltrojanowski
Copy link
Author

rafaltrojanowski commented Jan 12, 2022

For dev2 whe have:
answers_dev2_v3

Steps that I've done:

Read Json from file:

defmodule JsonToMap do
  def get_json(filename) do
    with {:ok, body} <- File.read(filename),
         {:ok, json} <- Poison.decode(body), do: {:ok, json}
  end
end

#how to access file from from bastion
template_map = JsonToMap.get_json("/Users/rafaltrojanowski/Projects/Zenloop/backend/apps/domain/priv/indexes/answers.json")

body = %{
  "index_patterns": [
    "answers",
    "answers*"
  ],
  "template": template_map
}
{:ok, response} = Domain.Env.get(:elasticsearch_url) |> URI.merge("/_index_template/answers_template/_mapping?pretty") |> URI.to_string() |> Elastix.HTTP.put()


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment