---
"Template request":

  - skip:
      version: " - 6.99.99"
      reason: the ranking evaluation feature is only available on 7.0

  - do:
     indices.create:
         index: foo
         body:
           settings:
             index:
               number_of_shards: 1
  - do:
      index:
        index:   foo
        type:    bar
        id:      doc1
        body:    { "text": "berlin" }

  - do:
      index:
        index:  foo
        type:   bar
        id:     doc2
        body:   { "text": "amsterdam" }

  - do:
      index:
        index:  foo
        type:   bar
        id:     doc3
        body:   { "text": "amsterdam" }
        
  - do:
      index:
        index:  foo
        type:   bar
        id:     doc4
        body:   { "text": "something about amsterdam and berlin" }

  - do:
      indices.refresh: {}

  - do:
      rank_eval:
        body: {
          "templates": [ { "id": "match", "template": {"source": "{\"query\": { \"match\" : {\"text\" : \"{{query_string}}\" }}}" }} ],
          "requests" : [
            {
                "id": "amsterdam_query",
                "params": { "query_string": "amsterdam" },
                "template_id": "match",
                "ratings": [
                    {"_index": "foo", "_id": "doc1", "rating": 0},
                    {"_index": "foo", "_id": "doc2", "rating": 1},
                    {"_index": "foo", "_id": "doc3", "rating": 1}]
            },
            {
                "id" : "berlin_query",
                "params": { "query_string": "berlin" },
                "template_id": "match",
                "ratings": [{"_index": "foo", "_id": "doc1", "rating": 1}]
            }
          ],
          "metric" : { "precision": { }}
        }

  - match: {quality_level: 0.5833333333333333}
  - match: {details.berlin_query.unknown_docs.0._id:  "doc4"}
  - match: {details.amsterdam_query.unknown_docs.0._id:  "doc4"}
