Skip to content

Instantly share code, notes, and snippets.

@dadoonet
Created November 8, 2013 17:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dadoonet/7374452 to your computer and use it in GitHub Desktop.
Save dadoonet/7374452 to your computer and use it in GitHub Desktop.
Bluekiwi example
curl -XDELETE "http://localhost:9200/bluekiwi"; echo
curl -XPUT "http://localhost:9200/bluekiwi/doc/1" -d'
{
"group":1,
"title":"test",
"content":"nothing",
"tags":["tag1","tag2"],
"authorId":1,
"creatorId":1
}'; echo
curl -XPUT "http://localhost:9200/bluekiwi/doc/2" -d'
{
"group":2,
"title":"test",
"content":"nothing",
"tags":["tag1","tag2"],
"authorId":1,
"creatorId":1
}'; echo
curl -XPUT "http://localhost:9200/bluekiwi/doc/3" -d'
{
"group":1,
"title":"nothing",
"content":"test",
"tags":["tag1","tag2"],
"authorId":1,
"creatorId":1
}'; echo
curl -XPUT "http://localhost:9200/bluekiwi/doc/4" -d'
{
"group":1,
"title":"nothing",
"content":"nothing",
"tags":["test","tag2"],
"authorId":1,
"creatorId":1
}'; echo
curl -XPUT "http://localhost:9200/bluekiwi/doc/5" -d'
{
"group":1,
"title":"test",
"content":"nothing",
"tags":["tag1","tag2"],
"authorId":0,
"creatorId":1
}'; echo
curl -XPUT "http://localhost:9200/bluekiwi/doc/6" -d'
{
"group":1,
"title":"test",
"content":"nothing",
"tags":["tag1","tag2"],
"authorId":1,
"creatorId":0
}'; echo
curl -XPUT "http://localhost:9200/bluekiwi/doc/7" -d'
{
"group":1,
"title":"test",
"content":"nothing",
"tags":["tag1","tag2"],
"authorId":0,
"creatorId":0
}'; echo
curl -XPOST "http://localhost:9200/bluekiwi/_refresh"; echo
curl -XPOST "http://localhost:9200/_search?pretty" -d'
{
"fields": [],
"query": {
"filtered": {
"query": {
"multi_match": {
"query": "test",
"fields": [ "title", "content", "tags"]
}
},
"filter": {
"and": {
"filters": [
{
"term": {
"group": 1
}
},{
"or": {
"filters": [
{
"term": {
"authorId": 1
}
},{
"term": {
"creatorId": 1
}
}
]
}
}
]
}
}
}
}
}'; echo
{
"took": 6,
"timed_out": false,
"_shards": {
"total": 10,
"successful": 10,
"failed": 0
},
"hits": {
"total": 5,
"max_score": 0.20876609,
"hits": [
{
"_index": "bluekiwi",
"_type": "doc",
"_id": "1",
"_score": 0.20876609
},
{
"_index": "bluekiwi",
"_type": "doc",
"_id": "6",
"_score": 0.20876609
},
{
"_index": "bluekiwi",
"_type": "doc",
"_id": "5",
"_score": 0.09415865
},
{
"_index": "bluekiwi",
"_type": "doc",
"_id": "3",
"_score": 0.09415865
},
{
"_index": "bluekiwi",
"_type": "doc",
"_id": "4",
"_score": 0.058849156
}
]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment