Hi, i have a document as follow {
"took": 0,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 4,
"max_score": 1,
"hits": [
{
"_index": "people",
"_type": "person",
"_id": "tqK1CmoBpUyg-koVON3h",
"_score": 1,
"_source": {
"fullName": "Person 3",
"totalSalary": 200000,
"positions": [
{
"name": "Teacher",
"isCurrentPosition": false,
"expirationDate": "2019-10-11T11:43:29.8168467+07:00",
"hasAverageLimitStatistic": false,
"averageMonthLimit": 3,
"salary": 0
},
{
"name": "TTTT",
"isCurrentPosition": false,
"expirationDate": "2019-10-11T11:43:29.8168467+07:00",
"hasAverageLimitStatistic": false,
"averageMonthLimit": 2,
"salary": 0
}
]
}
},
{
"_index": "people",
"_type": "person",
"_id": "tKK1CmoBpUyg-koVON3h",
"_score": 1,
"_source": {
"fullName": "Person 1",
"totalSalary": 100000,
"positions": [
{
"name": "Janitor",
"isCurrentPosition": false,
"expirationDate": "0001-01-01T00:00:00",
"monthsWorked": 3,
"hasAverageLimitStatistic": true,
"averageMonthLimit": 5,
"salary": 0
}
]
}
},
{
"_index": "people",
"_type": "person",
"_id": "taK1CmoBpUyg-koVON3h",
"_score": 1,
"_source": {
"fullName": "Person 2",
"totalSalary": 150000,
"positions": [
{
"name": "Coach",
"isCurrentPosition": false,
"expirationDate": "0001-01-01T00:00:00",
"hasAverageLimitStatistic": true,
"averageMonthLimit": 5,
"salary": 0
}
]
}
},
{
"_index": "people",
"_type": "person",
"_id": "t6K1CmoBpUyg-koVON3h",
"_score": 1,
"_source": {
"fullName": "Person 4",
"totalSalary": 250000,
"positions": [
{
"name": "Head",
"isCurrentPosition": false,
"expirationDate": "2021-04-11T11:43:29.8168467+07:00",
"hasAverageLimitStatistic": false,
"averageMonthLimit": 1,
"salary": 0
}
]
}
}
]
}
}
i want to get a list of people that have more positions than 1 . this is an array.i've tried as below
var searchResponse = client.Search(s => s.Type("person")
.Query(q => q.Nested(n =>
n.Path(p => p.Positions)//
.Query(qr => qr.Script(scr => scr.Source("doc['positions'].values.lenght > 1")
.Lang("painless"))))));
but it give me an error
Does any one have solutions for this problem ?