Skip to content

Instantly share code, notes, and snippets.

@tgxworld
Created May 7, 2015 03:01
Show Gist options
  • Save tgxworld/bd7d4e8dbfc43ad1de3d to your computer and use it in GitHub Desktop.
Save tgxworld/bd7d4e8dbfc43ad1de3d to your computer and use it in GitHub Desktop.
GET _count
DELETE _all
PUT organizations
{
"mappings": {
"document": {
"properties": {
"segments": {
"type": "nested"
},
"organization_id": {
"type": "integer",
"index": "not_analyzed"
}
}
}
}
}
POST organizations/document
{
"organization_id": 1,
"title": "Singapore Model",
"document_type": "pdf",
"file_name": "MyForumPostExport",
"segments": [
{
"content": "Some lessons I would like to share about econom....",
"tags": ["singapore", "education", "english"]
},
{
"content": "hope my own growth could move in tandem with the nation growth. Happy New Year!",
"tags": ["chinese", "student"]
},
{
"content": " individual schools do celebrate the success of their top scorers at the school level, except they cheer them in groups instead. Read",
"tags": ["school", "psle"]
}
]
}
POST _aliases
{
"actions": [{
"add": {
"index": "organizations",
"alias": "organization_1",
"filter": {"term": {"organization_id": 1}},
"routing": 1
}
}]
}
GET organizations/_aliases/*
GET organizations/document/_search
{
"query": {
"match_all": {}
}
}
GET /organization_1/document/_search
{
"query": {
"nested": {
"path": "segments",
"query": {
"match_phrase": {
"segments.content": "unique"
}
}
}
},
"query": {
"match_phrase": {
"title": "donkey"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment