algolia / algolia/docsearch

Allow Jquery for selectors besides Lvl0

Open
#2,194 0 comments 0 reactions 0 assignees View on GitHub
crawler Needs investigation
Dominant language
TypeScript
Stars
4.4k
Forks
439
Avg merge
14h 32m
Merged PRs (30d)
19

Description

## 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

Contributor guide

Open the contributing guide

Research direction

Start with the V3 recordExtractor and helpers.docsearch behavior shown in the issue, then compare how lvl0 selectors/defaultValue and lvl1+ values are processed. Verify completion with Algolia's URL Tester: jQuery-derived values should populate lvl1 and later levels without changing existing lvl0 behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, jquery, typescript
Domain
search
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.