How do I add custom pages or view pages to search index?
Yes, it's possible to provide a custom search index for either the Core/Search API module. Both modules are using the D8 plugin API to create their own plugin types for providing new indexing.


In Core, the SearchPlugin plugin type allows you to define the methods that you will need to implement for all aspects of search. To see how this works, look at the core UserSearch &amp; NodeSearch plugins to see how it interfaces with queries and indexing.
For SearchAPI, there are many different plugin types for interfacing with its different aspects of search. For brevity, you should start looking at the SearchApiDatasource plugin type to start providing a new indexable source.


In regards to an "abstract manner where the implementation would work using core database search or search api with solr," you're going to have to get clever with OOP and the plugin classes you're providing in your module if you want to do something like that. You're better off implementing each first, then abstracting later (if it provides benefits).