Skip to content

Latest commit

 

History

History

pages-custom-search

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Introduction

With this example, we show how you can perform custom searches on pages created with the Page Builder application, using the automatically included ElasticSearch client.

TIP: When it comes to performing advanced text and filtering queries, by default, every Webiny CMS project relies on Elasticsearch.

Once you implement this example, via your API Playground, you should be able to perform a text search like:

{
  pageBuilder {
    customSearchPages(where: { title: "welcome" }) {
      data {
        title
        path
      }
      meta {
        count
      }
      error {
        data
      }
    }
  }
}

Example Usage

Implementation

In order to implement this, we've simply created a new GraphQLSchemaPlugin, in ./api/code/graphql/src/plugins/pagesCustomSearch.ts.

Once created, we've imported and registered the plugin in ./api/code/graphql/src/index.ts

Sample Data

In order to easier understand how the ElasticSearch query works, we've included some sample data here. Notice how we have both latest: true and published: true entries for each page. So, when performing searches, you'll need to also append the proper filter (shown in the example code).