Skip to content

Instantly share code, notes, and snippets.

@alexbrasetvik
Created July 8, 2014 21:48
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 alexbrasetvik/619477700a24563d4e41 to your computer and use it in GitHub Desktop.
Save alexbrasetvik/619477700a24563d4e41 to your computer and use it in GitHub Desktop.
_type: parent
_id: 1
name: Ned
---
_type: child
_parent: 1
_id: 2
name: Arya
child:
_parent:
type: parent
#!/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": {}
}
}
}
}
'
# Auto generated by Found's Play-tool at 2014-07-08T23:48:32+02:00
version: 0
title: "Parent/Child-test"
description: ""
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