Created
January 13, 2017 23:51
-
-
Save xeraa/94f0ce87a053fe9f45f9cb380dbf961d to your computer and use it in GitHub Desktop.
Simulating a union query from SQL in Elasticsearch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DELETE my_index | |
PUT my_index | |
{ | |
"mappings": { | |
"my_type": { | |
"properties": { | |
"type": { | |
"type": "keyword" | |
} | |
} | |
} | |
} | |
} | |
GET my_index/_mapping | |
POST my_index/my_type/_bulk | |
{ "index": { "_id": 1 } } | |
{ "type": "text" } | |
{ "index": { "_id": 2 } } | |
{ "type": "text" } | |
{ "index": { "_id": 3 } } | |
{ "type": "text" } | |
{ "index": { "_id": 4 } } | |
{ "type": "text" } | |
{ "index": { "_id": 5 } } | |
{ "type": "word" } | |
{ "index": { "_id": 6 } } | |
{ "type": "word" } | |
{ "index": { "_id": 7 } } | |
{ "type": "word" } | |
{ "index": { "_id": 8 } } | |
{ "type": "word" } | |
GET my_index/_search | |
{ "query": { "match_all": {} } } | |
GET my_index/_msearch | |
{} | |
{ "query": { "term": { "type": "text" }}, "size": 3 } | |
{} | |
{ "query": { "term": { "type": "word" }}, "size": 3 } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment