Skip to content

New searchindex behaviour introduced with 4.3.0 seems to have broken searching #9915

@ViktorHaag

Description

@ViktorHaag

A primary reference here is PR #9649 .

The goal there, as I understand it, was to allow for several identically named objects appearing in different domains and for searchindex.js to find all those results.

The solution in the PR was to change the underlying data format in searchindex.js, switching from a Dict whose values are Dicts (of "name: Tuple of object info") to a Dict whose values are Lists (of items which are "Tuple of object info, now including name as the last element").

This seems to have changed the way that search results are presented in the list.

Here are some screen shots of my docs so you can see the difference.

The first list of search items for a search term is generated with Sphinx 4.2.0:
Screen Shot 2021-11-30 at 13 11 46

The second list of search items for a search term is from the same documentation source, rebuilt to a fresh output directory with Sphinx 4.3.1 (I observed the same result as this with Sphinx 4.3.0 as well):
Screen Shot 2021-11-30 at 13 14 24

In the source, I use the js domain to document the JSON structures for my REST API; for example, the dos for the Exemptions.ItemExemptionInfoFilter looks like this ("d2ljson" is a special enhanced version of JSON that allows me to document JSON showing type info, comments, and so on -- the lexing of the code block should have no effect at all on the JS attribute object; it's just content for that documentation item):

.. js:attribute:: Exemptions.ItemExemptionInfoFilter

    .. code-block:: d2ljson

       {
          "ExemptStartDate": <string:UTCDateTime>|null,
          "ExemptEndDate": <string:UTCDateTime>|null,
          "ExcludeGradedActivities": <boolean>|null,
          "ExcludeCompleteActivities": <boolean>|null
       }

In the first example where we used the old search method, searching presented back a search hit for Exemptions.ItemExemptionInfoFilter that went to the right place in the docs. For the second example with the new search method, it looks like the presentation of the search result is return the index of the part of the JS attribute name, and not the name of it ("1" vs "ItemExemptionInfoFilter").

Additionally, in the first example where we used the old search method, search hits on HTTP routes (API calls in my REST API) result. In the second example with the new search method, those search hits are completely missed. To document the HTTP routes, I use a slightly modified version of the sphinxcontrib-httpdomain extension. Code for a simple HTTP route API call looks like this:

.. http:post:: /d2l/api/le/(version)/(orgUnitId)/content/exemptions/users/(userId)/byFilter/
   :scopes: content:exemptions:write

   Create exemptions for content topics matching a specific filter for a user.

   :param version: API version.
   :type version: :term:`D2LVERSION`
   :param orgUnitId: Org unit ID.
   :type orgUnitId: :term:`D2LID`
   :param userId: User for whom to create the exemptions.
   :type userId: :term:`D2LID`
   :jsonparam ItemExemptionInfoFilter: Filter to select content items for exemption.
   :jtype ItemExemptionInfoFilter: :js:attr:`ItemExemptionInfoFilter <Exemptions.ItemExemptionInfoFilter>`
   :status 200: Action succeeded.
   :status 403: No permission to create exemptions
   :status 429: API :ref:`call-rate limit <rate-limiting>` exceeded.
   :since 1.47+: Route first appears in LMS v20.20.8.

   **Returns**. This action returns the created exemptions expressed in a
   :js:attr:`ItemExemptionInfo <Exemptions.ItemExemptionInfo>` JSON block.

You can see that this API route is found in the first set of search results produced with the 4.2.0 build, but not in the second set of search results from the 4.3.1 build.

I'm a bit of a loss as to how to achieve the goal of the original PR, but it seems clear to me that the PR is likely not working entirely as intended, and I'd request that we revert it until we have a more robust solution with more tests that can avoid results like above.

I'll try to provide more info or assistance here if I can, but I'm not sure what do do next.

How to Reproduce

Steps are very simple: do an HTML build with Sphinx 4.2.0 to show the original search results that present as I expect; then do an HTML build with Sphinx 4.3.1 to show the less useful search results.

Expected behavior

The presentation of search results should not change despite the changes in PR #9649 which should permit for new search results if the same object name gets used in several domains.

Your project

Unable to provide my own project as the documentation is internal.

Screenshots

Screen shots in description.

OS

MacOS 12.0.1

Python version

3.10.0

Sphinx version

4.3.1

Sphinx extensions

Our build uses a number of local extension modules; none directly to anything with Sphinx's search functionality. Our local 'httpdomain' and 'phpdomain' modules are wrappers/enhancements of the sphinxcontrib-provided domains.

    "sphinx.ext.autodoc",
    "sphinx.ext.extlinks",
    "sphinx.ext.intersphinx",
    "sphinx.ext.todo",
    "d2l_local",
    "d2l_htmlbuilder",
    "d2l_httpdomain",
    "d2l_phpdomain",
    "d2l_pygments",

Extra tools

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions