Skip to content

Instantly share code, notes, and snippets.

@olger
Last active December 14, 2015 01:29
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 olger/5006648 to your computer and use it in GitHub Desktop.
Save olger/5006648 to your computer and use it in GitHub Desktop.
This creates a new index with to documents of type 'project'. Thereafter it tries to find a project with the driver 'ural" that works with the 'match' option and is filtered with terms on the 'viewRights'
curl -XDELETE "http://localhost:9200/tip"
curl -XPOST "http://localhost:9200/tip/" -d '{}'
curl -XPUT 'http://localhost:9200/tip/project/_mapping' -d '
{
"project" : {
"properties" : {
"active" : {
"type" : "boolean"
},
"driver" : {
"type" : "string"
},
"driverAddress" : {
"type" : "string"
},
"driverEmail" : {
"type" : "string"
},
"driverPhone" : {
"type" : "string"
},
"due" : {
"type" : "date",
"format" : "dateOptionalTime"
},
"name" : {
"type" : "string"
},
"projectId" : {
"type" : "string",
"index" : "not_analyzed"
},
"stepDue" : {
"type" : "date",
"format" : "dateOptionalTime"
},
"stepOn" : {
"type" : "string"
},
"viewRights" : {
"type" : "string",
"index_name" : "viewRight",
"index" : "not_analyzed"
}
}
}
}
'
# "index" : "not_analyzed"
curl -XPUT 'localhost:9200/tip/project/124f4be0-7a82-11e2-a04a-15a79dd3d6a8' -d '{
"projectId" : "124f4be0-7a82-11e2-a04a-15a79dd3d6a8",
"active": true,
"name": "Installation",
"due": "2013-03-19T11:50:19+01:00",
"driver": "Allard Audi",
"driverAddress": "unknown yet",
"driverPhone": "234234234",
"driverEmail": "unknown yet",
"stepOn": "unknown yet",
"stepDue": "2013-03-20T09:04:44+01:00",
"viewRights": [ "1255ba55-e2bc-4888-b05b-d023a45923ab" ]
}'
curl -XPUT 'localhost:9200/tip/project/3a5f4be0-7a82-11e2-a04a-15a79dd3d6a9' -d '{
"projectId" : "3a5f4be0-7a82-11e2-a04a-15a79dd3d6a9",
"active": true,
"name": "Installation",
"due": "2013-03-19T11:50:19+01:00",
"driver": "Uri Ural",
"driverAddress": "unknown yet",
"driverPhone": "23484444",
"driverEmail": "unknown yet",
"stepOn": "unknown yet",
"stepDue": "2013-03-21T10:30:44+01:00",
"viewRights": [ "1255ba55-e2bc-4888-b05b-d023a45923ab", "3af5ba55-e2bc-4888-b05b-d023a45923cd" ]
}'
curl -XPUT 'localhost:9200/tip/project/321f4be0-7a82-11e2-a04a-15a79dd3d3ef' -d '{
"projectId" : "321f4be0-7a82-11e2-a04a-15a79dd3d3ef",
"active": true,
"name": "Installation",
"due": "2013-03-19T11:50:19+01:00",
"driver": "Ursula Ural",
"driverAddress": "unknown yet",
"driverPhone": "123456789",
"driverEmail": "unknown yet",
"stepOn": "unknown yet",
"stepDue": "2013-03-21T12:30:44+01:00",
"viewRights": [ "3af5ba55-e2bc-4888-b05b-d023a45923cd" ]
}'
curl -XPOST "http://localhost:9200/tip/_refresh"
curl -XPOST 'localhost:9200/tip/_search?pretty=true' -d '{"query":{"text":{"name":"Installation"}}}'
curl -XPOST 'localhost:9200/tip/_search?pretty=true' -d '{"query":{"term":{"name":"installation"}}}'
curl -XPOST 'localhost:9200/tip/_search?pretty=true' -d '{"query":{"term":{"viewRight":"1255ba55-e2bc-4888-b05b-d023a45923ab"}}}'
curl -XPOST 'localhost:9200/tip/_search?pretty=true' -d '{
"query":{
"match":{"driver":"ural"}
},
"filter":{
"terms" : {
"viewRights" : ["1255ba55-e2bc-4888-b05b-d023a45923ab", "3af5ba55-e2bc-4888-b05b-d023a45923cd"]
}
}
}'
curl -XPOST 'localhost:9200/tip/_search?pretty=true' -d '{
"query":{
"match":{"driver":"ural"}
},
"filter":{
"terms" : {
"viewRights" : ["1255ba55-e2bc-4888-b05b-d023a45923ab", "3af5ba55-e2bc-4888-b05b-d023a45923cd"]
}
},
"facets" : {
"active" : { "terms" : {"field" : "active"} }
}
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment