Indexing custom entity types I have two custom content entity types that I've created with a module. Neither one of these content entity types extends Node.

Our site has a search bar, and we want to include these two custom content entity types in the core search results (searching within the name of the entity only). 

The only demo I can find on this topic is this, but this doesn't seem to be working for me. I've modified the code to match the identifiers and properties of my custom entity type, placed the code in the module's src/Plugin folder, cleared the cache, but my entity type still does not appear as an option in /admin/config/search/pages. Only Content and Users continue to be available search pages. Additionally I am suspicious that this work for a custom content entity type since I am trying to match search index IDs with entity IDs in the queries within the code, but I think this consistency is only maintained for node entities.

I have also tried following this method of defining a search page through Views, but none of the options this poster has selected are available when I try to make a search page for a custom content entity type (for example "Search" as a filter criteria is not present).

I can't seem to find very much useful info on this topic and am wondering if there are any resources I'm simply missing or misunderstanding.
To answer the question, if an entity wants to be included in drupal search, it has to provide a search plugin, which is when discovered listed by the plugin manager from the search module. If not you should first check the annotations of the plugin, see for example the plugin from the node entity:

namespace Drupal\node\Plugin\Search;

/**
 * Handles searching for node entities using the Search module index.
 *
 * @SearchPlugin(
 *   id = "node_search",
 *   title = @Translation("Content")
 * )
 */
class NodeSearch extends ConfigurableSearchPluginBase implements AccessibleInterface, SearchIndexingInterface {


To debug this, clear the cache and list the discovered plugins:

drush ev "var_dump(\Drupal::service('plugin.manager.search')-&gt;getDefinitions())"


If all went well you have a third plugin here together with the node and user plugin and you should see it in the admin UI of the search module in the select box Search page type.



To give a recommendation, I agree with the commment from @Berdir. It's not worth the effort to write a custom search plugins, better use Search API:


  This module provides a framework for easily creating searches on any
  entity known to Drupal, using any kind of search engine.