Support Home > Search > Jetpack Search: Query Customization (Advanced)

Jetpack Search: Query Customization (Advanced)

Jetpack Search is a powerful replacement for the search capability built into WordPress. It is a paid upgrade to the Jetpack plugin that provides higher quality results and an improved search experience. Upgrade today to get started.

Note: This support article is intended for Jetpack Inline Search rather than the newer Jetpack Instant Search solution. Jetpack Inline Search is deprecated and we recommend all users switch to Jetpack Instant Search, our newer search solution. For more details on the difference between Inline Search and Instant Search, check out this page.

This support article covers how to customize Jetpack Search by using the Jetpack Search API and is intended for developers.

By default Jetpack Search will search everything to provide the best result. All records/documents (posts, pages, products, etc) on your site are searchable and will potentially be shown to end users. When sites are more complex though, you may want to limit the search based on what part of the site the user is currently on. Additionally, the API could be used to build features into a website or an app to provide better content discovery experiences.

The Jetpack Search engine combines data from multiple sources (your WordPress database and your stats/analytics) and indexes it into Elasticsearch. All search queries are Elasticsearch queries, though the engine will sometimes run multiple queries to get the best results. The API allows a subset of the Elasticsearch Query DSL and Aggregations to be used for filtering and aggregating on the search results.

If you have a request, our Github issues are always open. Please add the “Search” tag to your issue.

Supported Elasticsearch Filters

  • bool – supports AND (must), OR (should), and NOT (must_not)
  • exists – whether a field exists in the document
  • range – date or number ranges
  • term – individual terms in the index
  • terms – an OR of multiple terms

Any field can be queried with these. See the list of fields.

Supported Elasticsearch Aggregations

Allowed Aggregations:

For multiple reasons, not all fields can support aggregations.

Aggregations are Allowed on:

  • author_id
  • author_login
  • category.slug
  • category.slug_slash_name
  • category.term_id
  • date
  • date_gmt
  • date_gmt_token.*
  • date_token.*
  • like_count
  • meta.*.boolean (see details)
  • meta.*.date
  • meta.*.double
  • meta.*.long
  • meta.*.value.raw
  • modified_gmt_token.*
  • modified_token.*
  • modified
  • modified_gmt
  • post_format
  • post_status
  • post_type
  • tag.slug
  • tag.slug_slash_name
  • tag.term_id
  • taxonomy.*.slug (see details)
  • taxonomy.*.slug_slash_name
  • taxonomy.*.term_id

See details for these fields.

Document Fields

All fields available for filtering and aggregating on are documented on this page.

Frequently Asked Questions

Why do you limit the available queries and aggregations?

We want to ensure backwards compatibility so that 10 years from now, your queries will still keep working. The Elasticsearch project does not maintain the same level of backwards compatibility and we intend to shield our customers from needing to do unnecessary work.

There are also some features of Elasticsearch that do not scale well or can cause performance problems when used. By limiting the available queries, we hope to find the right balance between maintenance and flexibility.

What version of Elasticsearch are you running?

Above, we are linking to the Elasticsearch 2.4 documentation because that is what we are maintaining compatibility with. We have a query re-write layer which allows us to convert ES queries into whatever version of Elasticsearch we are running.

* Elasticsearch is a trademark of Elasticsearch BV, registered in the U.S. and in other countries.

If you have any further questions about Jetpack Search, please check out our related support documentation. If your questions aren’t answered there, feel free to contact us and we will be happy to help.

  • Table Of Contents

  • Categories

  • Contact Us

    Need more help? Feel free to contact us.