---
"validate query with synonyms":
  - do:
      indices.create:
        index: test
        body:
          settings:
            index:
              analysis:
                filter:
                  syns:
                    type: synonym
                    synonyms: [ "one,two" ]
                analyzer:
                  syns:
                    tokenizer: standard
                    filter: [ syns ]
          mappings:
            properties:
              field:
                type: text
                analyzer: syns

  - do:
      indices.validate_query:
        index: test
        explain: true
        body:
          query:
            match_phrase_prefix:
              field:
                query: foo

  - is_true: valid
  - length: { explanations: 1 }
  - match: { explanations.0.explanation: "/field:\"foo\\*\"/" }

  - do:
      indices.validate_query:
        index: test
        explain: true
        body:
          query:
            match_phrase_prefix:
              field:
                query: foo bar

  - is_true: valid
  - length: { explanations: 1 }
  - match: { explanations.0.explanation: "field:\"foo bar*\"" }

  - do:
      indices.validate_query:
        index: test
        explain: true
        body:
          query:
            match_phrase_prefix:
              field:
                query: one bar

  - is_true: valid
  - length: { explanations: 1 }
  - match: { explanations.0.explanation: "field:\"(one two) bar*\"" }

  - do:
      indices.validate_query:
        index: test
        explain: true
        body:
          query:
            match_phrase_prefix:
              field:
                query: foo one

  - is_true: valid
  - length: { explanations: 1 }
  - match: { explanations.0.explanation: "field:\"foo (one* two*)\"" }
