Is there a way to use regular expressions in index?

Hi Community,

I want to know if there is any way to use

StubIndexImpl.getInstance().get(JavaStubIndexKeys.FIELDS, "KEY", project, GlobalSearchScope.allScope(project));

with a regular expression for the key parameter?



There is no way to do so directly. You can use getAllKeys() and match them against a regular expression yourself, but this is a fairly expensive operation (therefore best done in a background thread).


Interesting - is getAllKeys itself an expensive operation? If so, would a file based index generally be a better solution for this type of query?


It's kind of expensive, yes. There is no difference in the performance of getting all keys for a stub index and a file-based index.


Please sign in to leave a comment.