How to create search indexes by path in Drupal 8? For a relatively small Drupal 8 website, I need to enable a search box, with multiple indexes based on the path or menu value.

For example; the main menu has 2 menu items linking to basic pages: Employers and Employees, and rest of the website pages are created under these two pages, and each page has a menu item with matching hierarchy.


Employers


Section A


Sub-section A-1
Sub-section A-2
Sub-section A-3

Section B


Sub-section B-1

Section C


Sub-section C-1
Sub-section C-2


Employees


Section D


Sub-section D-1
Sub-section D-2

Section E


Sub-section E-1
Sub-section E-2
Sub-section E-3
Sub-section E-4

Section F


Sub-section F-1
Sub-section F-2
Sub-section F-3




I need to be able to search only in Employers or Employees. And the search results must be limited to those indivual landing pages.

Thoughts?
I was able to resolve the issue by using the Views, not through the search indexes as I initially thought was the path for a solution.

Created a required field for the content-types that would be searched against. Let's call it Section for now, with the values of Employers and Employees. This will be used in the view to filter content by section. (Taxonomy terms can be used for this as well.)

Then created a view page for each section.



In the view, used Content for the row style with Search result highlighting input option, and sorted content by Search: Score (asc).

The real trick for this to work is enabling Search result highlighting input display mode and configuring it with the fields we want to be searched within.

Hope this helps who needs a similar solution in their projects.