How do I add custom pages or view pages to search index? Suppose I have a custom page built in a custom controller. Or similarly, a view page the displays the list of nodes, such as the classic "admin/content" page.   

I want certain user roles to be able to find this page when they search the site. The search does not have to index the entire view/page content, but rather a select parts of the content.    

Is this possible to do using core hooks? If not, then perhaps using search api hooks? 
I am thinking of hooking into the indexing process, and then, retrieve the pages I want to index and send them along. But I am not sure how to do this in a abstract manner where the implementation would work using core database search or search api with solr. 

Note Drupal 7 or 8 ideas would be much appreciated.
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).