Skip to content

Instantly share code, notes, and snippets.

@un1t
Created October 22, 2016 12:27
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 un1t/9e878c3800a6c80e8120ba514bd14ac5 to your computer and use it in GitHub Desktop.
Save un1t/9e878c3800a6c80e8120ba514bd14ac5 to your computer and use it in GitHub Desktop.
SIREn Join Plugin for Elasticsearch Example
curl -XPUT 'http://localhost:9200/_bulk?pretty' -d '
{ "index" : { "_index" : "test", "_type" : "publication", "_id" : "1" } }
{ "title" : "The NoSQL database glut", "journal" : "2", "author": "1" }
{ "index" : { "_index" : "test", "_type" : "publication", "_id" : "2" } }
{ "title" : "Graph Databases Seen Connecting the Dots", "journal" : "1", "author": "2"}
{ "index" : { "_index" : "test", "_type" : "publication", "_id" : "3" } }
{ "title" : "How to determine which NoSQL DBMS best fits your needs", "journal" : "2", "author": "3" }
{ "index" : { "_index" : "test", "_type" : "publication", "_id" : "4" } }
{ "title" : "MapR ships Apache Drill", "journal" : "4", "author": "4" }
{ "index" : { "_index" : "test", "_type" : "journal", "_id" : "1" } }
{ "id": "1", "name" : "Zrulem" }
{ "index" : { "_index" : "test", "_type" : "journal", "_id" : "2" } }
{ "id": "2", "name" : "Nauka" }
{ "index" : { "_index" : "test", "_type" : "journal", "_id" : "3" } }
{ "id": "3", "name" : "Playboy" }
{ "index" : { "_index" : "test", "_type" : "journal", "_id" : "4" } }
{ "id": "4", "name" : "Maxim" }
{ "index" : { "_index" : "test", "_type" : "author", "_id" : "1" } }
{ "id": "1", "name" : "Vasya", "age": 6}
{ "index" : { "_index" : "test", "_type" : "author", "_id" : "2" } }
{ "id": "2", "name" : "Petya", "age": 8 }
{ "index" : { "_index" : "test", "_type" : "author", "_id" : "3" } }
{ "id": "3", "name" : "Vovan", "age": 10 }
{ "index" : { "_index" : "test", "_type" : "author", "_id" : "4" } }
{ "id": "4", "name" : "Timur", "age": 16 }
'
curl -XGET 'http://localhost:9200/test/_coordinate_search?pretty' -d '{
"query" : {
"bool" : {
"filter" : [
{
"filterjoin" : {
"journal" : {
"indices" : ["test"],
"types" : ["journal"],
"path" : "id",
"query" : {
"match" : {
"name" : "Nauka"
}
}
}
}
},
{
"filterjoin" : {
"author" : {
"indices" : ["test"],
"types" : ["author"],
"path" : "id",
"query" : {
"range" : {
"age" : {"gte": 10}
}
}
}
}
}
]
}
}
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment