Skip to content

Conversation

@antidis
Copy link

@antidis antidis commented Jun 11, 2018

This meant that words like docs-snippet were being indexed as docs and snippet, but would be searched for as docs-snippet.

I'm not sure that method of sharing state is particularly great, but we can't import from lib/broccoli, or require from addon/services.

There's some good suggestions over here on how search could be further improved with a Lunr pipeline: olivernn/lunr.js#296

index.js Outdated
projectHref: info && info.browse(),
deployVersion: 'ADDON_DOCS_DEPLOY_VERSION'
deployVersion: 'ADDON_DOCS_DEPLOY_VERSION',
searchTokenSeparator: /\s+/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless I'm mistaken, a regex won't survive the JSON.stringify pass that happens when config is serialized for the app. Can we add a test to verify this is working?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works fine for the dummy app:

screen shot 2018-06-11 at 15 35 04

I'll get a test in place.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added. I'm open to a different location for the test.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like that's working because the search terms aren't being split at all — that means if I search e.g. render multiple with your changes, I get no results, but on the latest deployed version of the site, that returns several options back.

It looks like the regex is being encoded as {} in the serialized config:

screen shot 2018-06-11 at 1 00 46 pm

await visit('/sandbox');

assert.equal(modulePage.searchResults.items.length, 0, 'no search results shown');
await modulePage.fillInSearchQuery('sub-subsection');
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oddly enough, the search works as every character of sub-subsection is typed out, except when the query is sub-subsecti or sub-subsectio.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense to me — Lunr's stemmer likely recognizes ion as a strippable suffix, so it's actually indexing that word as sub-subsect. When you enter sub-subect yourself, that matches directly, and when you enter sub-subsection completely, it gets stemmed the same way, but sub-subsecti and sub-subsectio would both be left alone by the stemmer, so they wouldn't match.

@antidis
Copy link
Author

antidis commented Jun 11, 2018

Pushed a change to reencode the RegExp as a string, that then gets converted to a RegExp.

Copy link
Contributor

@dfreeman dfreeman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @antidis!

@dfreeman dfreeman merged commit 1a22df3 into ember-learn:master Jun 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants