Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Jquery for selectors besides Lvl0 #2194

Open
ForgoneReality opened this issue Feb 27, 2024 · 0 comments
Open

Allow Jquery for selectors besides Lvl0 #2194

ForgoneReality opened this issue Feb 27, 2024 · 0 comments
Labels
crawler issue related to the indexing Needs investigation Investigation is planned but not started yet

Comments

@ForgoneReality
Copy link

Describe the problem

Hi! I'm trying to migrate from V2 to V3, and in V2 I had a working xpath for both lvl0 and lvl1. When changing to V3, I changed my lvl0 one to JQuery from XPath and it works fine. However, lvl1 doesn't work at all.

actions: [
    {
      indexName: "mydex",
      pathsToMatch: ["https://test.com/docs/**"],
      recordExtractor: ({ $, helpers }) => {
        // priority order: deepest active sub list header -> navbar active item -> 'Documentation'
        const breads = $(
          "li.breadcrumbs__item.breadcrumbs__item--active span",
        ).text();
        const top_menu = $("a.menu__link--active").eq(0).text();
        return helpers.docsearch({
          recordProps: {
            lvl0: {
              selectors: "",
              defaultValue: breads,
            },
            lvl1: top_menu,
            lvl2: "article h2",
            lvl3: "article h3",
            lvl4: "article h4",
            lvl5: "article h5, article td:first-child",
            lvl6: "article h6",
            content: "article p, article li, article td:last-child",
          },
          aggregateContent: true,
          recordVersion: "v3",
        });
      },
    },
  ],

When using Algolia's URL Tester, lvl1 is always null. However, when I set it to this:

  lvl0: {
              selectors: "",
              defaultValue: top_menu,
            },
            lvl1: breads,

Suddenly, top_menu starts to work, and lvl1 is now all null.

Describe the solution

Allow lvl1+ to use Jquery for more complex matches like in legacy Docsearch please!

Alternatives you've considered

@randombeeper randombeeper added crawler issue related to the indexing Needs investigation Investigation is planned but not started yet labels Jul 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crawler issue related to the indexing Needs investigation Investigation is planned but not started yet
Projects
None yet
Development

No branches or pull requests

2 participants