Skip to content

Conversation

jsnmoon
Copy link
Contributor

@jsnmoon jsnmoon commented Aug 26, 2019

Changes proposed in this Pull Request:

When a user performs a search using a Jetpack Search widget, the search page will now include a dynamically generated list of filters on the sidebar like so:

Screen Shot 2019-08-26 at 4 18 28 PM

The checkbox inputs are currently disabled at this time. Instant Search remains gated by a JETPACK_SEARCH_PROTOTYPE define.

Is this a new feature or does it add/remove features to an existing part of Jetpack?

  • Yes, this is a new feature being added onto Jetpack Instant Search (p3QzjZ-V3).

Testing instructions:

  • Add define( "JETPACK_SEARCH_PROTOTYPE", true ); to your wp-config.php.
  • Ensure that your site has the Jetpack Pro plan and has Jetpack Search enabled.
  • Add a Jetpack Search widget to the Search page sidebar.
  • Add a filter or two to the Jetpack Search widget.
  • Enter a query into a search widget.
    Alternatively, navigate to a search page like /?s=privacy.
  • Ensure that you see a list of disabled checkboxes in the Search page sidebar.

Proposed changelog entry for your changes:

  • No changelog entry necessary; these changes will not be accessible to our users.

@jsnmoon jsnmoon added [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it [Status] Needs Review This PR is ready for review. [Feature] Search For all things related to Search Instant Search labels Aug 26, 2019
@jsnmoon jsnmoon requested review from gibrown and a team August 26, 2019 22:25
@jsnmoon jsnmoon self-assigned this Aug 26, 2019
@jetpackbot
Copy link
Collaborator

jetpackbot commented Aug 26, 2019

Thank you for the great PR description!

When this PR is ready for review, please apply the [Status] Needs Review label. If you are an a11n, please have someone from your team review the code if possible. The Jetpack team will also review this PR and merge it to be included in the next Jetpack release.

Scheduled Jetpack release: September 3, 2019.
Scheduled code freeze: August 27, 2019

Generated by 🚫 dangerJS against f624a3a

Copy link
Member

@gibrown gibrown left a comment

Choose a reason for hiding this comment

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

Looking good. We could hold off on the filter results formatting, etc for another PR given the current size. Also there is some overlap with my PR and merging this could help us clean that up. I think the two blockers are that the search box is disappearing for me and the asset size stuff.

type="checkbox"
/>
<label htmlFor={ `jp-instant-search-filter-dates-${ bucket.key_as_string }` }>
{ strip( bucket.key_as_string ) } ({ bucket.doc_count })
Copy link
Member

Choose a reason for hiding this comment

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

This should get localized and we should remove the hours, minutes, secs. There is some config in the date config that indicates if we are displaying months or years.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When you say date config, are you referring to a query value that could be specified in the API request?

Copy link
Member

Choose a reason for hiding this comment

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

Ya there is interval information from the widget filter config: https://cloudup.com/cD3amQW3Ba1

That should be applied both for the API request and for determining how to display the results (if year, then only show the year, if month, then show year and month).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could we push the interval formatting and localization to the API? Otherwise, we'll need to consider adding a date formatting library to the client, which could add a minimum of 15kB to our production bundle.

The interval value is already being passed in the API call.

Copy link
Member

Choose a reason for hiding this comment

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

Possibly ya. Is the 15kb from pulling in https://www.npmjs.com/package/@wordpress/date which looks like it includes date_i18n()? We may want something like this anyways to correctly display in search results though.

]
// TODO: Remove this reverse & slice when API adds filter count support
.reverse()
.slice( 0, 5 ) }
Copy link
Member

Choose a reason for hiding this comment

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

I think the count comes from the config.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The API currently throws a 400 when I specify a size query value for aggregations[date_histogram_0][date_histogram][size]. See this example query.

Copy link
Member

Choose a reason for hiding this comment

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

Ya, the api will always return all of them, but we have an option (https://cloudup.com/cD3amQW3Ba1) that lets the user indicate how many to show. 5 shouldn't be hard coded.

Copy link
Contributor Author

@jsnmoon jsnmoon Aug 29, 2019

Choose a reason for hiding this comment

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

Is it possible to support the size query value as it does for taxonomy and post_type aggregations?

In the meanwhile, I'll look into linking up the widget configuration values to the aggregation values in the client in a follow-up PR.

Copy link
Member

Choose a reason for hiding this comment

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

ES doesn't support it itself, so we would have to post process is somehow on the API side. I'd rather not deviate from the ES standards for aggs and filters though as that could make things harder to support long term.

@jeherve jeherve added [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. and removed [Status] Needs Review This PR is ready for review. labels Aug 28, 2019
@jsnmoon jsnmoon added [Status] In Progress and removed [Status] In Progress [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. labels Aug 28, 2019
@jsnmoon jsnmoon added the [Status] Needs Review This PR is ready for review. label Aug 29, 2019
@jsnmoon jsnmoon requested a review from gibrown August 29, 2019 21:05
@gibrown
Copy link
Member

gibrown commented Aug 29, 2019

@jsnmoon since we are going to try a separate branch to merge into, maybe what is in here is good to go and you should just make a new PR against that branch, I or @bluefuton can cast some eyes over it and then we can handle the bug and display fixes in separate PRs?

…ion (#13365)

Refactor search results and improve their display. Add display of when we make spelling corrections.
@gibrown
Copy link
Member

gibrown commented Aug 30, 2019

I have opened this PR against the instant-search-master instead in #13371

@jeherve jeherve added [Status] Blocked / Hold and removed [Status] Needs Review This PR is ready for review. labels Sep 3, 2019
@jsnmoon
Copy link
Contributor Author

jsnmoon commented Sep 3, 2019

We'll be continuing this work in #13371 and landing our work in a feature branch instead of in master.

@jsnmoon jsnmoon closed this Sep 3, 2019
@gibrown gibrown deleted the add/filtering-for-instant-search branch September 4, 2019 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Search For all things related to Search Touches WP.com Files [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants