Skip to content

Instantly share code, notes, and snippets.

@TomonoriSoejima
TomonoriSoejima / role_and_user.md
Last active November 6, 2020 12:33
role and user
GET /_xpack/security/user/

GET /_xpack/security/role/
@TomonoriSoejima
TomonoriSoejima / alias_sample.md
Last active November 6, 2020 12:32
alias sample
POST /_aliases
{
    "actions" : [
        { "add" : { "indices" : ["hotel", "hotel2"], "alias" : "alias1" } }
    ]
}


@TomonoriSoejima
TomonoriSoejima / get_node_status_1.md
Last active November 6, 2020 12:22
watcher script sample
PUT _xpack/watcher/watch/my-watch1
{
  "trigger": {
    "schedule": {
      "interval": "30m"
    }
  },
  "input": {
 "http": {
@TomonoriSoejima
TomonoriSoejima / powershell.msearch.md
Last active November 6, 2020 07:23
_msearch sample in powershell
$USER = "elastic"
$PASS = "changeme"
$secpasswd = ConvertTo-SecureString $PASS -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential($USER, $secpasswd)


$uri = "http://localhost:9200/_msearch"

# make sure to add extra epmty line in $body
@TomonoriSoejima
TomonoriSoejima / dynamic_mapping_test.md
Last active November 6, 2020 12:22
dynamic mapping test
DELETE test


PUT test
{
  "mappings": {
    "my_type": {
      "numeric_detection": true
 }
@TomonoriSoejima
TomonoriSoejima / multi_match.md
Last active November 6, 2020 07:32
multiple search sample
GET /hotel/_search
{
  "query": {
    "multi_match" : {
      "query":      "tofu ramen Yakitori",
      "type":       "best_fields",
      "fields":     [ "dinner_menu", "lunch_menu" ],
      "tie_breaker": 0.3,
 "operator": "and"
@TomonoriSoejima
TomonoriSoejima / cloud_dictionary_upload_sample.md
Last active November 6, 2020 12:24
cloud dictionary upload sample
# note that elasticsearch/config/test.txt should exist

PUT /test
{
  "settings": {
    "analysis": {
      "filter": {
        "my_synonym_filter": {
          "type": "synonym", 
delete t
PUT /t
{
  "settings": {
    "index": {
      "analysis": {
        "filter": {
          "engram": {
            "type": "edgeNGram",
@TomonoriSoejima
TomonoriSoejima / time_format_test.md
Last active November 6, 2020 12:24
time format test
DELETE a2

PUT a2
{
  "mappings": {
    "a": {
      "properties": {
        "created": {
 "type": "date"
@TomonoriSoejima
TomonoriSoejima / look_for_escape_character.md
Last active November 6, 2020 12:25
look for escape character
DELETE test4

PUT /test4
{
  "mappings": {
    "test": {
      "properties": {
        "name": {
 "type": "text",