Skip to content

Instantly share code, notes, and snippets.

@sohangp
sohangp / modifyIndex.sh
Last active June 20, 2019 15:21
Modify Index with a Wife
curl -X PUT 'http://localhost:9200/family_tree/_mapping'
-H 'content-type: application/json' \
-d '{
"properties":{
"relation_type":{
"type":"join",
"eager_global_ordinals":true,
"relations":{
"parent":[ "child", "wife" ]
}
@sohangp
sohangp / has_parent_femaleParent.sh
Last active June 20, 2019 15:08
Get All Children who's Parent is a 'Female'
curl -X GET 'http://localhost:9200/family_tree/_search?pretty=true' \
-H 'content-type: application/json' \
-d '{
"query":{
"has_parent":{
"parent_type":"parent",
"query":{
"match":{
"gender":"Female"
}
@sohangp
sohangp / has_Child_DeadDaughters.sh
Last active June 20, 2019 15:17
Get All parents who have daughters who are dead
curl -X GET 'http://localhost:9200/family_tree/_search?pretty=true' \
-H 'content-type: application/json' \
-d '{
"query":{
"has_child":{
"type":"child",
"query":{
"bool":{
"must":[
{ "match":{ "gender":"Female" } },
@sohangp
sohangp / childrenOfDarrenWhoAreAlive.sh
Last active June 20, 2019 15:06
Get All children of Darren who are alive
curl -X GET 'http://localhost:9200/family_tree/_search?pretty=true' \
-H 'content-type: application/json' \
-d '{
"query":{
"bool":{
"filter":{
"term":{
"isAlive":true
}
},
@sohangp
sohangp / querySiennaChildren.sh
Last active June 20, 2019 15:04
Query all Sienna Children
curl -X GET 'http://localhost:9200/family_tree/_search?pretty=true' \
-H 'content-type: application/json' \
-d '{
"query":{
"parent_id":{
"type":"child",
"id":"2"
}
}
}'
@sohangp
sohangp / createDarren.sh
Last active June 20, 2019 14:49
Inserting Darren Ford
curl -X PUT 'http://localhost:9200/family_tree/_doc/1?routing=Darren' \
-H 'content-type: application/json' \
-d '{
"firstName":"Darren",
"lastName":"Ford",
"gender":"Male",
"isAlive":false,
"relation_type":{
"name":"parent"
}
@sohangp
sohangp / insertChildren.sh
Last active June 20, 2019 15:01
Insert all the 9 Children
# Insert Children for Darren
curl -X PUT \
'http://localhost:9200/family_tree/_bulk?routing=Darren' -H 'content-type: application/json' \
-d '
{"index": {"_type": "_doc", "_id": "4"}}
{"firstName":"Otis", "lastName":"Ford", "gender":"Male", "isAlive":false, "relation_type":{ "name":"child", "parent":"1" } }
{"index": {"_type": "_doc", "_id": "5"}}
{"firstName":"Pearl", "lastName":"Ford", "gender":"Female", "isAlive":true, "relation_type": { "name":"child", "parent":"1" } }
{"index": {"_type": "_doc", "_id": "6"}}
{"firstName":"Ava", "lastName":"Ford", "gender":"Female", "isAlive":true, "relation_type": { "name":"child", "parent":"1" } }
@sohangp
sohangp / createPearl.sh
Last active June 20, 2019 15:04
Inserting Pearl Ford
curl -X PUT 'http://localhost:9200/family_tree/_doc/5?routing=Darren' \
-H 'content-type: application/json' \
-d '{
"firstName":"Pearl",
"lastName":"Ford",
"gender":"Female",
"isAlive":true,
"relation_type":{
"name":"child",
"parent":"1"
@sohangp
sohangp / createParent.sh
Last active November 5, 2019 06:37
Creating Parent Data
curl -X PUT 'http://localhost:9200/family_tree/_doc/1?routing=Darren' \
-H 'content-type: application/json' \
-d '{
"firstName":"Darren",
"lastName":"Ford",
"gender":"Male",
"isAlive":false,
"relation_type":{
"name":"parent"
}
@sohangp
sohangp / createIndex.sh
Last active June 20, 2019 14:38
Create Game Of Thrones Index
curl -X PUT 'http://localhost:9200/family_tree' -H 'content-type: application/json' \
-d '{
"settings": {
"index": {
"number_of_shards": 2,
"number_of_replicas": 2
}
},
"mappings": {
"properties": {