Skip to content

Instantly share code, notes, and snippets.

@rhoboat
Last active January 3, 2018 18:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rhoboat/976cd398e0bed5283e443b7eec39b592 to your computer and use it in GitHub Desktop.
Save rhoboat/976cd398e0bed5283e443b7eec39b592 to your computer and use it in GitHub Desktop.
mappings and reindex scripts

Not allowed:

"mappings": {
  "tweet": {
    "properties": {
      "innerTweet": {
        "properties": {
          "title": {
            "type": "keyword"
          },
          "title": {
            "type": "long"
          }
        }
      }
    }
  }
}
"mappings": {
  "tweet": {
    "properties": {
      "title": {
        "type": "keyword"
      },
    },
  },
  "user": {
    "properties": {
      "title": {
        "type": "long"
      }
    }
  }
}

Allowed:

"mappings": {
  "doc": {
    "properties": {
      "type": {
        "type:" "keyword"
      },
      "tweet": {
        "properties": {
          "title": {
            "type": "keyword"
          },
        },
      },
      "user": {
        "properties": {
          "title": {
            "type": "long"
          }
        }
      }
    }
  }
}

Creating:

POST /indexname/doc/tweet:abc123/_create
{
  "type": "tweet",
  "tweet": {
    "title": "some keyword"
  }
}

POST /indexname/doc/user:abc123/_create
{
  "type": "user",
  "tweet": {
    "title": 23045987234
  }
}

Getting:

GET /indexname/doc/tweet:abc123
{
  "_type": "doc",
  "_id": "tweet:abc123",
  "_source": {
    "type": "tweet",
    "tweet": {
      "title": "some keyword"
    }
  }
}

POST /indexname/doc/user:abc123
{
  "_type": "doc",
  "_id": "user:abc123",
  "_source": {
    "type": "user",
    "tweet": {
      "title": 23045987234
    }
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment