Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

Search: surface pattern type in query input#63326

Merged
jtibshirani merged 6 commits into
mainfrom
jtibs/patterntype
Jun 19, 2024
Merged

Search: surface pattern type in query input#63326
jtibshirani merged 6 commits into
mainfrom
jtibs/patterntype

Conversation

@jtibshirani

Copy link
Copy Markdown
Contributor

We plan to remove the 'Keyword Search' toggle as part of bringing the feature
to GA. Once the toggle is removed, the search UX will only represent keyword
(the default pattern type) and regexp (through the regex toggle), with no
visual indication for other pattern types. So if a user clicks on a link using
patterntype:standard, the search will just behave differently, without any
indication in the UX as to why.

This PR surfaces the patterntype filter in the search bar whenever it's not
keyword or regexp. That way, users can see an old pattern type is being
used and understand why the search behavior may be different.

Relates to SPLF-68

Test plan

Added unit tests, manually tested search bar behavior with different pattern
types.

@cla-bot cla-bot Bot added the cla-signed label Jun 19, 2024
@github-actions github-actions Bot added team/product-platform team/search-platform Issues owned by the search platform team labels Jun 19, 2024
patternTypeInput?: SearchPatternType
}

export function literalSearchCompatibility({ queryInput, patternTypeInput }: QueryCompatibility): QueryCompatibility {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Previously, we attempted to automatically convert patterntype:literal searches to patterntype:standard. It found it surprising to rewrite the user's query from under them after they submit it. Also, I don't see a strong reason to do this, since we still support the literal pattern type in the backend (and kind of need to, until we explicitly mark it unsupported).

This logic led to extra weird UX with this PR, where if your query has patterntype:literal, then when you submit it, we immediately replace it with patterntype:standard. So I just removed this.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

we still support the literal pattern type in the backend

Do we want to always support patterntype:literal though? I think this was intended to help nudge users in the direction of the newer search syntax. I expect we will still want ways to provide that nudge, especially if we ever want to try to get rid of the regex toggle. I don't feel strongly about this specific way of doing it though, so deleting this is fine with me.

@jtibshirani jtibshirani Jun 19, 2024

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think this was a reasonable approach at the time to teach people about the new standard syntax. But now literal usage is so rare that it's not worth keeping this around.

As a general note, I'd prefer if we don't rewrite people's queries in the UX without an explicit action. Swapping out the query is tricky, and discourages people from fixing the root cause of the old pattern type (perhaps it's a custom search engine or old link). In this PR we're gently encouraging them to switch to keyword, by making the old pattern type look obviously non-default and a bit clunky :)

@jtibshirani

Copy link
Copy Markdown
Contributor Author

Noting one slightly weird thing with this PR: the patterntype:standard might "move around" in the query after you submit. Let's say you're typing this ...
Screenshot 2024-06-18 at 5 13 36 PM
Then after submitting it's written to this...
Screenshot 2024-06-18 at 5 14 10 PM

I don't think this is a big deal, especially since the vast majority of patterntype:standard input will be coming through the URL (through custom search engines or links to old searches).

@jtibshirani jtibshirani requested review from a team June 19, 2024 00:15
@jtibshirani jtibshirani marked this pull request as ready for review June 19, 2024 01:36
@stefanhengl

stefanhengl commented Jun 19, 2024

Copy link
Copy Markdown
Member

Noting one slightly weird thing with this PR: the patterntype:standard might "move around" in the query after you submit. Let's say you're typing this ... Screenshot 2024-06-18 at 5 13 36 PM Then after submitting it's written to this... Screenshot 2024-06-18 at 5 14 10 PM

I don't think this is a big deal, especially since the vast majority of patterntype:standard input will be coming through the URL (through custom search engines or links to old searches).

Could we avoid this by checking whether the query string already contains a patternType: filter?

EDIT: Ignore that. I see that we remove the pattern type from the query when we construct the URL, so the information about the position is lost.

@stefanhengl stefanhengl left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

There is another weird thing. We change from camelCase to lowercase for the same reason we don't have the positional information anymore.

I think the weirdness is acceptable since we don't expect users to actually type these pattern types very often.

Comment thread client/web/src/stores/navbarSearchQueryState.ts Outdated
@linear linear Bot mentioned this pull request Jun 19, 2024
4 tasks
@jtibshirani

Copy link
Copy Markdown
Contributor Author

I just found a bad bug: if you are in patterntype:standard mode, clicking the regex toggle no longer works. I'll make sure to test more extensively and squash bugs before merging.

@camdencheek camdencheek left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM pending the regex toggle fix!

patternTypeInput?: SearchPatternType
}

export function literalSearchCompatibility({ queryInput, patternTypeInput }: QueryCompatibility): QueryCompatibility {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

we still support the literal pattern type in the backend

Do we want to always support patterntype:literal though? I think this was intended to help nudge users in the direction of the newer search syntax. I expect we will still want ways to provide that nudge, especially if we ever want to try to get rid of the regex toggle. I don't feel strongly about this specific way of doing it though, so deleting this is fine with me.

@jtibshirani

jtibshirani commented Jun 19, 2024

Copy link
Copy Markdown
Contributor Author

I fixed the toggle issue in 7a4af03. It turned out pretty tricky and not up to my usual standards :( I tried a few other things but couldn't find an alternative approach. I'm okay with it since we're rewriting all of this into sveltekit (and the architecture is looking much simpler...)

@jtibshirani jtibshirani merged commit 5630eef into main Jun 19, 2024
@jtibshirani jtibshirani deleted the jtibs/patterntype branch June 19, 2024 21:24
jtibshirani added a commit that referenced this pull request Jun 25, 2024
Previously, enabling then disabling the regexp toggle would always set the
patterntype to `keyword`, even when the user has set
`search.defaultPatternType: standard`. Now, toggles always revert back to the
default pattern type.

To support this, this PR adds `defaultPatternType` to the nav bar query state,
which is updated every time there's a settings update. Having
`defaultPatternType` available also lets us fix another bug: when
the default pattern type has been set to `standard` we no longer awkwardly show
`patterntype: standard` in the search bar. (This confusing behavior was
introduced recently in #63326.)

**Overall, this PR set us up to remove `experimentalFeatures.keywordSearch`,
along with the keyword search toggle.** To opt out of keyword search, users can
just set `search.defaultPatternType`, and have it work everywhere.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cla-signed team/product-platform team/search-platform Issues owned by the search platform team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants