How to search with specific keyword order

If there is an data like below :

this is a test line contain notepad.exe.
this is not the line I want which contain notepad.exe for test

and hypothesis, I dont know all words in above sentence, what I know is below :

  1. the sentence contains keyword 'test'
  2. the sentence contains keyword 'notepad.exe'
  3. keyword is in strict order: 'exe' after 'notepad', 'notepad' after 'test'
  4. all keywords may not consecutively

Because reason 4, I can not use match_phrase query,so is there any way I can pick out first line with DSL query ?

Look into span queries. They are not very performant, but offer loads more
flexibility than standard phrase queries.

https://www.elastic.co/guide/en/elasticsearch/reference/master/span-queries.html

Hi,

You can also do this:

{
  "query": {
    "query_string": {
      "query": "\"test notepad.exe\"~2",
      "default_operator": "AND"
    
    }
  }
}

https://www.elastic.co/guide/en/elasticsearch/reference/2.1/query-dsl-query-string-query.html#_proximity_searches