Thank you very much for this suggestion. Maybe I'm wrong but both queries will not give me what I want.
- If I mark documents with year marker then doing select I will just receive orders from 2017 or from 2018 (I will not know if the company that placed order in 2017 is new or not).
- looks like second query is choosing documents with order date 2018-01-01, 2018-12-31 and not 2017-01-01, 2017-12-31. But we do not know if those companies with order date 2018-X-X are new or not.
But maybe I'm taking ES nested query in wrong way.