Created
July 8, 2014 21:48
-
-
Save alexbrasetvik/619477700a24563d4e41 to your computer and use it in GitHub Desktop.
This file contains 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
_type: parent | |
_id: 1 | |
name: Ned | |
--- | |
_type: child | |
_parent: 1 | |
_id: 2 | |
name: Arya |
This file contains 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
child: | |
_parent: | |
type: parent |
This file contains 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
#!/bin/bash | |
export ELASTICSEARCH_ENDPOINT="http://localhost:9200" | |
# Create indexes | |
curl -XPUT "$ELASTICSEARCH_ENDPOINT/play" -d '{ | |
"mappings": { | |
"child": { | |
"_parent": { | |
"type": "parent" | |
} | |
} | |
} | |
}' | |
# Index documents | |
curl -XPOST "$ELASTICSEARCH_ENDPOINT/_bulk?refresh=true" -d ' | |
{"index":{"_index":"play","_type":"parent","_id":1}} | |
{"name":"Ned"} | |
{"index":{"_index":"play","_type":"child","_parent":1,"_id":2}} | |
{"name":"Arya"} | |
' | |
# Do searches | |
curl -XPOST "$ELASTICSEARCH_ENDPOINT/_search?pretty" -d ' | |
{ | |
"query": { | |
"has_parent": { | |
"parent_type": "parent", | |
"query": { | |
"match_all": {} | |
} | |
} | |
} | |
} | |
' | |
This file contains 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
# Auto generated by Found's Play-tool at 2014-07-08T23:48:32+02:00 | |
version: 0 | |
title: "Parent/Child-test" | |
description: "" |
This file contains 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
query: | |
has_parent: | |
parent_type: parent | |
query: | |
match_all: {} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment