# Integration tests for the expert scoring script example plugin
#
---
setup:
  - do:
      indices.create:
          index:  test

  - do:
      index:
        index:  test
        type:   test
        id:     1
        body:   { "important_field": "foo" }
  - do:
        index:
          index:  test
          type:   test
          id:     2
          body:   { "important_field": "foo foo foo" }
  - do:
        index:
          index:  test
          type:   test
          id:     3
          body:   { "important_field": "foo foo" }

  - do:
      indices.refresh: {}
---
"document scoring":
  - do:
      search:
        index: test
        body:
          query:
            function_score:
              query:
                match:
                  important_field: "foo"
              functions:
                - script_score:
                    script:
                      source: "pure_df"
                      lang: "expert_scripts"
                      params:
                        field: "important_field"
                        term: "foo"

  - length: { hits.hits: 3 }
  - match: {hits.hits.0._id: "2" }
  - match: {hits.hits.1._id: "3" }
  - match: {hits.hits.2._id: "1" }
