0
0
Fork 0

add integration tests for sorting

This commit is contained in:
Marty Schoch 2016-08-20 14:45:53 -04:00
parent 2311d060d1
commit 1ae938b781
8 changed files with 491 additions and 0 deletions

View File

@ -0,0 +1,8 @@
{
"id": "a",
"name": "marty",
"age": 19,
"born": "2014-11-25",
"title": "mista",
"tags": ["gopher", "belieber"]
}

View File

@ -0,0 +1,8 @@
{
"id": "b",
"name": "steve",
"age": 21,
"born": "2000-09-11",
"title": "zebra",
"tags": ["thought-leader", "futurist"]
}

View File

@ -0,0 +1,8 @@
{
"id": "c",
"name": "aster",
"age": 21,
"born": "1954-02-02",
"title": "blogger",
"tags": ["red", "blue", "green"]
}

View File

@ -0,0 +1,7 @@
{
"id": "d",
"age": 65,
"born": "1978-12-02",
"title": "agent",
"tags": ["cats"]
}

View File

@ -0,0 +1,7 @@
{
"id": "e",
"name": "nancy",
"born": "1954-10-22",
"title": "rapstar",
"tags": ["pain"]
}

View File

@ -0,0 +1,7 @@
{
"id": "f",
"name": "frank",
"age": 1,
"title": "taxman",
"tags": ["vitamin","purple"]
}

View File

@ -0,0 +1,3 @@
{
}

View File

@ -0,0 +1,443 @@
[
{
"comment": "default order, all have same score, then by natural index order",
"search": {
"from": 0,
"size": 10,
"query": {
"match_all":{}
}
},
"result": {
"total_hits": 6,
"hits": [
{
"id": "a"
},
{
"id": "b"
},
{
"id": "c"
},
{
"id": "d"
},
{
"id": "e"
},
{
"id": "f"
}
]
}
},
{
"comment": "sort by name, ascending",
"search": {
"from": 0,
"size": 10,
"query": {
"match_all":{}
},
"sort": ["name"]
},
"result": {
"total_hits": 6,
"hits": [
{
"id": "c"
},
{
"id": "f"
},
{
"id": "a"
},
{
"id": "e"
},
{
"id": "b"
},
{
"id": "d"
}
]
}
},
{
"comment": "sort by name, descending",
"search": {
"from": 0,
"size": 10,
"query": {
"match_all":{}
},
"sort": ["-name"]
},
"result": {
"total_hits": 6,
"hits": [
{
"id": "b"
},
{
"id": "e"
},
{
"id": "a"
},
{
"id": "f"
},
{
"id": "c"
},
{
"id": "d"
}
]
}
},
{
"comment": "sort by name, descending, missing first",
"search": {
"from": 0,
"size": 10,
"query": {
"match_all":{}
},
"sort": [{"by":"field","field":"name","missing":"first","desc":true}]
},
"result": {
"total_hits": 6,
"hits": [
{
"id": "d"
},
{
"id": "b"
},
{
"id": "e"
},
{
"id": "a"
},
{
"id": "f"
},
{
"id": "c"
}
]
}
},
{
"comment": "sort by age, ascending",
"search": {
"from": 0,
"size": 10,
"query": {
"match_all":{}
},
"sort": ["age"]
},
"result": {
"total_hits": 6,
"hits": [
{
"id": "f"
},
{
"id": "a"
},
{
"id": "b"
},
{
"id": "c"
},
{
"id": "d"
},
{
"id": "e"
}
]
}
},
{
"comment": "sort by age, descending",
"search": {
"from": 0,
"size": 10,
"query": {
"match_all":{}
},
"sort": ["-age"]
},
"result": {
"total_hits": 6,
"hits": [
{
"id": "d"
},
{
"id": "b"
},
{
"id": "c"
},
{
"id": "a"
},
{
"id": "f"
},
{
"id": "e"
}
]
}
},
{
"comment": "sort by age, descending, missing first",
"search": {
"from": 0,
"size": 10,
"query": {
"match_all":{}
},
"sort": [{"by":"field","field":"age","missing":"first","desc":true}]
},
"result": {
"total_hits": 6,
"hits": [
{
"id": "e"
},
{
"id": "d"
},
{
"id": "b"
},
{
"id": "c"
},
{
"id": "a"
},
{
"id": "f"
}
]
}
},
{
"comment": "sort by born, ascending",
"search": {
"from": 0,
"size": 10,
"query": {
"match_all":{}
},
"sort": ["born"]
},
"result": {
"total_hits": 6,
"hits": [
{
"id": "c"
},
{
"id": "e"
},
{
"id": "d"
},
{
"id": "b"
},
{
"id": "a"
},
{
"id": "f"
}
]
}
},
{
"comment": "sort by born, descending",
"search": {
"from": 0,
"size": 10,
"query": {
"match_all":{}
},
"sort": ["-born"]
},
"result": {
"total_hits": 6,
"hits": [
{
"id": "a"
},
{
"id": "b"
},
{
"id": "d"
},
{
"id": "e"
},
{
"id": "c"
},
{
"id": "f"
}
]
}
},
{
"comment": "sort by born, descending, missing first",
"search": {
"from": 0,
"size": 10,
"query": {
"match_all":{}
},
"sort": [{"by":"field","field":"born","missing":"first","desc":true}]
},
"result": {
"total_hits": 6,
"hits": [
{
"id": "f"
},
{
"id": "a"
},
{
"id": "b"
},
{
"id": "d"
},
{
"id": "e"
},
{
"id": "c"
}
]
}
},
{
"comment": "sort on multi-valued field",
"search": {
"from": 0,
"size": 10,
"query": {
"match_all":{}
},
"sort": [{"by":"field","field":"tags","mode":"min"}]
},
"result": {
"total_hits": 6,
"hits": [
{
"id": "a"
},
{
"id": "c"
},
{
"id": "d"
},
{
"id": "b"
},
{
"id": "e"
},
{
"id": "f"
}
]
}
},
{
"comment": "multi-column sort by age, ascending, name, ascending (flips b and c which have same age)",
"search": {
"from": 0,
"size": 10,
"query": {
"match_all":{}
},
"sort": ["age", "name"]
},
"result": {
"total_hits": 6,
"hits": [
{
"id": "f"
},
{
"id": "a"
},
{
"id": "c"
},
{
"id": "b"
},
{
"id": "d"
},
{
"id": "e"
}
]
}
},
{
"comment": "sort by docid descending",
"search": {
"from": 0,
"size": 10,
"query": {
"match_all":{}
},
"sort": ["-_id"]
},
"result": {
"total_hits": 6,
"hits": [
{
"id": "f"
},
{
"id": "e"
},
{
"id": "d"
},
{
"id": "c"
},
{
"id": "b"
},
{
"id": "a"
}
]
}
}
]