filter : Does not calculate the relevance score, has better performance, no sorting, and the data of the more commonly used filters are cached inside the ES.
query : The relevance score will be calculated, with poor performance, sorting, and no caching.
So in fact, in summary, when you need to do a full-text search or need to calculate a relevance score, use query, otherwise filter is preferred.