I think you should generalize this in a utils methods like
```Java
public void ensureNotDeleteByQuery(QueryParser parser, QueryParseContext parseContext) {
  if ("delete_by_query".equals(SearchContext.current().source())) {
    throw new QueryParsingException(parseContext.index(), "[" + parser.names()[0] + "] unsupported in delete_by_query api");
  }
}
```

that way you only need to have that logic in one place....