elasticsearch nest query和aggs同时

时间:2017-01-12 13:57:42

标签: elasticsearch nest

使用Nest 5,我正在尝试发出查询请求并对结果进行聚合:

在elasticsearch中,就是这种类型的请求:

POST /index/mappingname/_search
{
   "query": {
      "match": {
        "street": "wellington"
      }
   },
    "aggs" : {
        "agg_name" : {
            "terms" : {
                "field" : "country"
            }
        }
    }, 
    "size" : 0
}

1 个答案:

答案 0 :(得分:0)

       var segmentStore : [Int] = []

        // Iterate through the array
        // keeping track of the elements

        for element : Int in segmentStore {



            //if the segment store arrays segment (index) is equal to 0 then...
            if segmentStore[element] == 0 // ---ERROR HERE---
            {

                //declare constant variable with random number between 1 and 25
                aGen[0] = Int(arc4random_uniform(25) + 1)

                //variable lChar segment 0 is equal to the following code plus existing contents
                lChar[0] += String(alphabet[alphabet.index(alphabet.startIndex, offsetBy: String.IndexDistance(aGen[0]))])

                //print the value in array
                print("seg 0 \(element)")
            }

            //if the segment store arrays segment (index) is equal to 1 then...
            else if segmentStore[element] == 1
            {

                aGen[1] = Int(arc4random_uniform(9))

                lChar[1] += String(aGen[1])

                //print the value in array
                print("seg 1 \(element)")
            }

            //if the segment store arrays segment (index) is equal to 2 then...
            else if segmentStore[Int(element)] == 2
            {

                //declare constant variable with random number between 1 and 25
                aGen[2] = Int(arc4random_uniform(25) + 1)

                //variable lChar segment 0 is equal to the following code plus existing contents
                lChar[2] += String(alphabet[alphabet.index(alphabet.startIndex, offsetBy: String.IndexDistance(aGen[2]))])

                //print the value in array
                print("seg 2\(element)")
            }

            else
            {
            print("error!!!")
                erCode = 1
                messageBox()
            }

        }