You're missing the '+' or '-' to show what type of filter it is (inclusion or exclusion). Instead try this: -generated-sources

The filter is then applied against every search folder and because the '-' specifies an exclusion filter any folder with generated-sources
in its path would be excluded from the search.
Your regular expression .*\\generated-sources\\.*
would still work with the '-' applied, ie -.*\\generated-sources\\.*
, but the solution above is a little simpler and therefore a little faster.
More information
To understand how Persistent Search Filters are applied imagine that they are simply appended to the end of your search path. So if you were searching in C:\My\Folders
and had both the 'SVN/HG' and 'Recycle bin' filters applied, internally the Look In functionality would be:
C:\My\Folders;-:regex:\\(\.svn|\.hg|\.git|cvs)\\;-recycle
You may have noticed a little undocumented feature here. The filter can specify the expression type as part of the filter, in this case :regex:
specified that the filter should be treated as a regular expression. The complete list of filter expression types are:
:bool:
- Boolean expression
:boolre:
- Boolean RegEx
:regex:
- Regular expression
:word:
- Whole word
:dos:
- DOS expression