### Programmatic Examples Source: https://developers.wpengine.com/docs/wp-engine-ai-toolkit/smart-search/getting-started Examples of how to make requests programmatically using JavaScript (Node.js) and Python. ```APIDOC ## JavaScript (Node.js) Example ### Description This example demonstrates how to perform a search using the `fetch` API in Node.js. ### Code ```javascript const GQL_ENDPOINT = '{your-smart-search-url}'; const SEARCH_TOKEN = '{your-search-token}'; async function search(query) { const response = await fetch(GQL_ENDPOINT, { method: 'POST', headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${SEARCH_TOKEN}`, }, body: JSON.stringify({ query: ` query FindQuery($query: String!) { find(query: $query) { total documents { id data } } } `, variables: { query: query, }, }), }); const result = await response.json(); console.log(JSON.stringify(result, null, 2)); } search('hello world'); ``` ## Python Example ### Description This example demonstrates how to perform a search using the `requests` library in Python. ### Code ```python import requests import json GQL_ENDPOINT = "{your-smart-search-url}" # It is highly recommended to use the read-only Search Token for client-side applications. SEARCH_TOKEN = "{your-search-token}" def search(query): headers = { "Content-Type": "application/json", "Authorization": f"Bearer {SEARCH_TOKEN}", } graphql_query = { "query": """ query FindQuery($query: String!) { find(query: $query) { total documents { id data } } } """, "variables": { "query": query } } response = requests.post(GQL_ENDPOINT, headers=headers, data=json.dumps(graphql_query)) response.raise_for_status() result = response.json() print(json.dumps(result, indent=2)) search("hello world") ``` ``` -------------------------------- ### Update Package.json Start Script for Node Adapter Source: https://developers.wpengine.com/docs/atlas/framework-guides/astro How to add a 'start' script to your package.json file to ensure the project starts correctly using the Node adapter for the Headless Platform. ```json { "scripts": { ... "start": "node ./dist/server/entry.mjs" ... } } ``` -------------------------------- ### Add Start Script to package.json Source: https://developers.wpengine.com/docs/atlas/framework-guides/sveltekit Modification of `package.json` to include a 'start' script that runs the Node adapter build output. This script is used by hosting platforms to start the application. ```json { "scripts": { ... "start": "node build" ... } } ``` -------------------------------- ### Container Build Summary Example Source: https://developers.wpengine.com/docs/atlas/reference/cli/wpe/builds/get Provides a summary of a container build process, including the start time, end time, and total duration. This information is useful for performance monitoring. ```text ----------Summary - Container Build start---------- Start:2021-01-01 00:00:12.720617455 +0000 UTC End:2021-01-01 00:00:46.866221598 +0000 UTC Duration:34.146 seconds ----------Summary - Container Build end------------ ``` -------------------------------- ### API Authentication and Request Example Source: https://developers.wpengine.com/docs/atlas/reference/api/authentication This section details how to generate API credentials and provides an example of how to make a GET request to the Headless Platform API using these credentials. ```APIDOC ## API Authentication ### Description This document provides instructions on how to obtain authorization to use the Headless Platform API. Once authorized, you can send requests directly or via the Endpoints documentation section. This setup is designed to simplify testing of the Headless Platform API. ### Prerequisites To enable this functionality, you first need to generate authentication credentials. You can do this by navigating to the WP Engine User Portal. From the left-hand menu, select `Users`, then the `API Access tab`, and finally `Generate Credentials`. ### Using the Headless Platform API With authentication credentials generated, you can start sending requests to the Headless Platform API. Below is an example of such a request: ### Method GET ### Endpoint https://js.wpengineapi.com/v1/accounts/{PUT_ACCOUNT_NAME_HERE}/apps ### Parameters #### Query Parameters None #### Path Parameters - **PUT_ACCOUNT_NAME_HERE** (string) - Required - The name of the account for which to retrieve applications. #### Request Body None ### Request Example ```bash curl -X GET -H "Content-Type: application/json" -u "PUT_API_USERNAME_HERE:PUT_API_PASSWORD_HERE" https://js.wpengineapi.com/v1/accounts/{PUT_ACCOUNT_NAME_HERE}/apps ``` ### Response #### Success Response (200) - **accounts** (array) - A list of accounts associated with the provided credentials. - **name** (string) - The name of the account. - **apps** (array) - A list of applications within the account. - **name** (string) - The name of the application. - **framework** (string) - The framework used by the application. - **status** (string) - The current status of the application. #### Response Example ```json { "accounts": [ { "name": "example-account-name", "apps": [ { "name": "example-app-name", "framework": "next", "status": "active" } ] } ] } ``` ### Error Handling - **401 Unauthorized**: Invalid API username or password. - **404 Not Found**: The specified account name does not exist. ``` -------------------------------- ### Create New SvelteKit Project Source: https://developers.wpengine.com/docs/atlas/framework-guides/sveltekit Command to initialize a new SvelteKit application. This command requires Node.js and npm/npx to be installed. ```bash npx sv create my-sveltekit-app ``` -------------------------------- ### Update Build and Start Scripts for Node.js Integration Source: https://developers.wpengine.com/docs/atlas/framework-guides/qwik Commands to stage, commit, and push changes after configuring the Qwik app for Node.js integration by updating the 'start' script in package.json. This ensures the application builds and runs correctly on the headless platform. ```bash # Stage all changed files $ git add -A # Commit the files to the current branch $ git commit -m "update build and start" # Push changes to remote repository $ git push -u origin main ``` -------------------------------- ### Example Output Structure for wpe builds get Source: https://developers.wpengine.com/docs/atlas/reference/cli/wpe/builds/get Illustrates the typical output format when using the 'wpe builds get' command. This includes various build-related metadata and potentially error information if the build failed. ```text ID: sqeq3na34owo8see7xwro5o8 APP_NAME: myapp ENVIRONMENT: bmna3gedlzerwcb4vc04gssl REPOSITORY: organization/myapp BRANCH: main TIMESTAMP: 2021-01-01T00:00:46Z COMMIT_SHA: 71234c6 ERROR: ... ``` -------------------------------- ### Install Node Adapter for SvelteKit Source: https://developers.wpengine.com/docs/atlas/framework-guides/sveltekit Command to install the Node.js adapter for SvelteKit as a development dependency. Requires npm or yarn to be installed. ```bash npm i -D @sveltejs/adapter-node ``` -------------------------------- ### Initialize Gatsby Project Source: https://developers.wpengine.com/docs/atlas/framework-guides/gatsby Command to create a new Gatsby project. Users can select WordPress as a CMS option during installation for pre-configured settings. ```bash npm init gatsby ``` -------------------------------- ### Configure Custom Start Commands in package.json Source: https://developers.wpengine.com/docs/atlas/platform-guides/customizing-builds Specify custom start scripts in your package.json. The 'start' script is the default, but can be overridden by the HEADLESS_START_SCRIPT environment variable. 'start-dev' is provided as an example for development environments. ```json { "scripts": { "start": "next start", "start-dev": "next dev" } } ``` -------------------------------- ### Programmatic Search Request in Python Source: https://developers.wpengine.com/docs/wp-engine-ai-toolkit/smart-search/getting-started This example shows how to make a search request programmatically using the `requests` library in Python. It requires your GraphQL endpoint and a search token. The function constructs headers and a JSON payload with the GraphQL query and variables, sends a POST request, and prints the JSON response. ```python import requests import json GQL_ENDPOINT = "{your-smart-search-url}" # It is highly recommended to use the read-only Search Token for client-side applications. SEARCH_TOKEN = "{your-search-token}" def search(query): headers = { "Content-Type": "application/json", "Authorization": f"Bearer {SEARCH_TOKEN}", } graphql_query = { "query": """ query FindQuery($query: String!) { find(query: $query) { total documents { id data } } } """, "variables": { "query": query } } response = requests.post(GQL_ENDPOINT, headers=headers, data=json.dumps(graphql_query)) response.raise_for_status() result = response.json() print(json.dumps(result, indent=2)) search("hello world") ``` -------------------------------- ### Configure Gatsby Start Command Source: https://developers.wpengine.com/docs/atlas/framework-guides/gatsby Modifies the `start` script in `package.json` to use `gatsby serve --port 3000`. This ensures the Gatsby application listens on the correct port when running on the Headless Platform. ```json "start": "gatsby serve --port 3000" ``` -------------------------------- ### Smart Search API Authentication and Basic Search Source: https://developers.wpengine.com/docs/wp-engine-ai-toolkit/smart-search/getting-started This section covers how to authenticate your requests using an access token and demonstrates a basic search query. ```APIDOC ## POST /graphql ### Description This endpoint allows you to perform searches using the Smart Search API. Authentication is required via a Bearer token in the `Authorization` header. ### Method POST ### Endpoint `{your-smart-search-url}` ### Parameters #### Header Parameters - **Authorization** (string) - Required - `Bearer {your-search-token}` - **Content-Type** (string) - Required - `application/json` #### Request Body - **query** (string) - Required - The GraphQL query string. ### Request Example ```json { "query": "query { find(query: \"hello world\") { total } }" } ``` ### Response #### Success Response (200) - **data** (object) - Contains the search results. - **find** (object) - **total** (integer) - The total number of matching documents. #### Response Example ```json { "data": { "find": { "total": 123 } } } ``` ``` -------------------------------- ### Install gatsby-source-wordpress Package Source: https://developers.wpengine.com/docs/atlas/framework-guides/gatsby Manually installs the `gatsby-source-wordpress` npm package, which is essential for connecting the Gatsby data layer to a WordPress site. ```bash npm install -save gatsby-source-wordpress ``` -------------------------------- ### Commit and Push Package.json Script Changes Source: https://developers.wpengine.com/docs/atlas/framework-guides/astro Commands to stage, commit, and push the changes made to the package.json file, specifically the 'start' script update. ```bash # Stage all changed files $ git add -A # Commit the files to the current branch $ git commit -m "replace start script in package.json" # Push changes to remote repository $ git push -u origin main ``` -------------------------------- ### Create Next.js Project and Install Dependencies Source: https://developers.wpengine.com/docs/wp-engine-ai-toolkit/examples/rag-chatbot-example/rag-chatbot-example Command to create a new Next.js application and install necessary AI SDK and UI dependencies. This sets up the foundation for integrating AI search capabilities. ```bash npx create-next-app@latest name-of-your-app npm install @ai-sdk/google ai openai-edge react-icons react-markdown ``` -------------------------------- ### Clone Next.js WordPress Starter Templates Source: https://developers.wpengine.com/docs/atlas/framework-guides/next-js/next Commands to clone starter templates for Next.js projects integrated with headless WordPress. These templates are designed for specific setups like WPGatsby or WPGraphQL. ```bash $ git clone https://github.com/colbyfayock/next-wordpress-starter ``` ```bash $ git clone https://github.com/colbyfayock/next-wpgraphql-basic-starter ``` ```bash $ git clone https://github.com/JEverhart383/crash-course-headless-wp-next-wpgraphql ``` -------------------------------- ### Programmatic Search Request in JavaScript (Node.js) Source: https://developers.wpengine.com/docs/wp-engine-ai-toolkit/smart-search/getting-started This example demonstrates how to make a search request programmatically using the built-in `fetch` API in Node.js (v18+) or modern browsers. It requires your GraphQL endpoint and a search token. The function sends a POST request with a JSON body containing the GraphQL query and variables, then logs the JSON response. ```javascript const GQL_ENDPOINT = '{your-smart-search-url}'; const SEARCH_TOKEN = '{your-search-token}'; async function search(query) { const response = await fetch(GQL_ENDPOINT, { method: 'POST', headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${SEARCH_TOKEN}`, }, body: JSON.stringify({ query: ` query FindQuery($query: String!) { find(query: $query) { total documents { id data } } } `, variables: { query: query, }, }), }); const result = await response.json(); console.log(JSON.stringify(result, null, 2)); } search('hello world'); ``` -------------------------------- ### Check pnpm Version Locally Source: https://developers.wpengine.com/docs/atlas/platform-guides/customizing-builds Retrieve the version of pnpm installed on your local development environment. This helps confirm local pnpm setup. ```bash $ pnpm --version 9.2.0 ``` -------------------------------- ### Make GET Request to Headless Platform API using cURL Source: https://developers.wpengine.com/docs/atlas/reference/api/authentication This cURL command demonstrates how to make a GET request to the Headless Platform API to retrieve account information. It requires API username and password, and the account name as parameters. Ensure you replace the placeholder values with your actual credentials and account name. ```shell curl -X GET -H "Content-Type: application/json" -u "PUT_API_USERNAME_HERE:PUT_API_PASSWORD_HERE" https://js.wpengineapi.com/v1/accounts/{PUT_ACCOUNT_NAME_HERE}/apps ``` -------------------------------- ### Check Yarn Version Locally Source: https://developers.wpengine.com/docs/atlas/platform-guides/customizing-builds Display the version of Yarn currently installed on your local machine. This command is useful for verifying your local Yarn setup. ```bash $ yarn --version 1.22.16 ``` -------------------------------- ### Serve SPA with Express in Node.js Source: https://developers.wpengine.com/docs/atlas/framework-guides/spa Example Node.js code using the Express framework to serve static assets and handle client-side routing for a Single Page Application. It configures the server to respond with index.html for all routes, allowing the SPA's client-side router to manage navigation. Assumes the static build output is in a 'build' directory. ```javascript const express = require('express'); const path = require('path'); const app = express(); app.use(express.static(path.join(__dirname, 'build'))); app.get('/*', function (req, res) { res.sendFile(path.join(__dirname, 'build', 'index.html')); }); app.listen(8080); ``` -------------------------------- ### Basic Smart Search Request with cURL Source: https://developers.wpengine.com/docs/wp-engine-ai-toolkit/smart-search/getting-started This snippet shows how to perform a basic search query using the cURL command-line tool. It requires your GraphQL endpoint and an access token for authentication. The request sends a POST request with JSON data containing the search query and returns the total number of matching documents. ```bash curl -X POST \ -H "Content-Type: application/json" \ -H "Authorization: Bearer {your-search-token}" \ --data '{ "query": "query { find(query: \"hello world\") { total } }" }' \ {your-smart-search-url} ``` -------------------------------- ### Get Specific Build Information using wpe builds get Source: https://developers.wpengine.com/docs/atlas/reference/cli/wpe/builds/get Retrieves detailed information about a specific build for an application's environment. Requires the build ID as an argument. The output includes details like ID, app name, environment, repository, branch, timestamp, commit SHA, and any errors. ```bash $ wpe builds get $BUILD_ID [OPTIONS] $ wpe builds get sqeq3na34owo8see7xwro5o8 ``` -------------------------------- ### Initialize and Push Git Repository Source: https://developers.wpengine.com/docs/atlas/framework-guides/spa Commands to initialize a local Git repository, add a remote origin, stage all files, commit changes, and push to the remote repository. This is the initial step to make your project available for deployment. ```bash # Add remote repository $ git remote add origin https://.com// # Stage all changed files $ git add -A # Commit the files to the current branch $ git commit -m "initial commit" # Push changes to remote repository $ git push -u origin main ``` -------------------------------- ### Initialize and Configure Git Repository Source: https://developers.wpengine.com/docs/atlas/framework-guides/qwik Commands to add a remote repository, stage all files, commit changes, and push to the remote repository. This is essential for deploying your project to a version control system. ```bash # Add remote repository $ git remote add origin https://// # Stage all changed files $ git add -A # Commit the files to the current branch $ git commit -m "initial commit" # Push changes to remote repository $ git push -u origin main ``` -------------------------------- ### Initialize Local Git Repository and Commit Source: https://developers.wpengine.com/docs/atlas/framework-guides/sveltekit Commands to initialize a new Git repository, stage all files, and make the initial commit. These are essential for version control and deployment preparation. ```bash git init && git add -A && git commit -m "Initial commit" ``` -------------------------------- ### Clone WordPress Blog Starter Template Source: https://developers.wpengine.com/docs/atlas/framework-guides/gatsby Clones a starter template specifically designed for headless WordPress blogs, providing a pre-built structure for integration. ```bash git clone https://github.com/gatsbyjs/gatsby-starter-wordpress-blog ``` -------------------------------- ### Initialize Git Repository and Push to Remote Source: https://developers.wpengine.com/docs/atlas/framework-guides/next-js/next Commands to initialize a local Git repository, add a remote origin, commit changes, and push to a remote repository for deployment. This is a standard process for deploying projects to platforms that use Git for version control. ```bash # Add remote repository $ git remote add origin https://// # Stage all changed files $ git add -A # Commit the files to the current branch $ git commit -m "initial commit" # Push changes to remote repository $ git push -u origin main ``` -------------------------------- ### Initialize and Push Git Repository to Remote Source: https://developers.wpengine.com/docs/atlas/framework-guides/astro Commands to add a remote repository, stage all files, commit changes, and push to the remote repository. This is essential for deploying your project. ```bash #Add remote repository $ git remote add origin https://// # Stage all changed files $ git add -A # Commit the files to the current branch $ git commit -m "initial commit" # Push changes to remote repository $ git push -u origin main ``` -------------------------------- ### Create New Next.js Project Source: https://developers.wpengine.com/docs/atlas/framework-guides/next-js/next Command to create a new Next.js project. Ensure you select the Pages Router if prompted, to be compatible with legacy Next.js 12. ```bash $ npx create-next-app@latest ``` -------------------------------- ### Initialize Git Repository and Push to Remote Source: https://developers.wpengine.com/docs/atlas/framework-guides/gatsby Commands to set up a remote Git repository and push initial project files. This includes adding the remote origin, staging all changes, committing them, and pushing to the main branch. ```bash #Add remote repository $ git remote add origin https://// # Stage all changed files $ git add -A # Commit the files to the current branch $ git commit -m "initial commit" # Push changes to remote repository $ git push -u origin main ``` -------------------------------- ### Check npm Version Locally Source: https://developers.wpengine.com/docs/atlas/platform-guides/customizing-builds Determine the currently installed version of npm on your local system. This helps in debugging and ensuring that your local setup matches the intended build environment. ```bash $ npm --version 8.11.0 ``` -------------------------------- ### Filter with Wildcards in GraphQL Source: https://developers.wpengine.com/docs/wp-engine-ai-toolkit/smart-search/find-api Uses wildcard characters within filter expressions for pattern matching. The asterisk `*` matches zero or more characters, enabling flexible searches like titles starting with 'Ted'. Example: `post_title:Ted*`. ```graphql query WildcardFilterQuery { find(query: "*", filter: "post_title:Ted*") { total documents { id } } } ``` -------------------------------- ### POST /v1/accounts/{account}/apps/{app}/environments Source: https://developers.wpengine.com/docs/atlas/reference/api/endpoints/operations/apps_createenvironment Creates a new environment for a specified Headless Platform application. This involves defining the build source, display name, and linking it to a WordPress environment. ```APIDOC ## POST /v1/accounts/{account}/apps/{app}/environments ### Description Creates a new environment for a specified Headless Platform application. This involves defining the build source, display name, and linking it to a WordPress environment. ### Method POST ### Endpoint /v1/accounts/{account}/apps/{app}/environments ### Parameters #### Path Parameters - **account** (string) - Required - Name of your WP Engine Headless Platform account - **app** (string) - Required - Name of your Headless Platform application #### Request Body - **branch** (string) - Required - The branch name from which the Environment is going to be built. In case of using .zip upload, the value should equal to `uploadable` - **build** (string) - Optional - Build name in the format of: `accounts/{account}/apps/{app}/builds/{build}`. A Build describes steps taken to deploy (activate) the Environment. - **createTime** (string format: date-time) - Optional - The timestamp when the environment was created. - **displayName** (string) - Required - A name of the Environment used for display purposes - **domains** (Array) - Optional - A list of domains associated with the Environment. - **name** (string) - Optional - Environment name in the format of: `accounts/{account}/apps/{app}/environments/{environment}` - **reconciling** (boolean) - Optional - An Environment is marked as reconciling if its current state does not match the user’s requested intended state and the system is working to reconcile them. - **rootDirectory** (string) - Optional - Root directory in which customer code is located. - **shellVariables** (Array) - Optional - A list of environment variables available in the environment’s container. - **key** (string) - Required - Environment variable key. Must match regex: `[-._a-zA-Z][-._a-zA-Z0-9]*`. Must not match any of the following case-insensitive globs: WPE_*, ATLAS_METADATA*, HEADLESS_METADATA_*, HOME, PORT, K_*, TMP, TMPDIR, TEMP_ - **value** (string) - Required - Environment variable value. - **updateTime** (string format: date-time) - Optional - The timestamp when the environment was most recently updated. - **wpEnvironment** (string) - Required - Name of the WordPress environment linked with this Environment. The Environment will have the same access visibility as wp_environment. ### Request Example ```json { "branch": "main", "displayName": "My Production Environment", "wpEnvironment": "wp_engine_prod" } ``` ### Response #### Success Response (200) - **done** (boolean) - Information if the operation is done or still in progress - **metadata** (object) - Long running operation metadata - **@type** (string) - A URL/resource name that uniquely identifies the type of the serialized protocol buffer message - **build** (string) - Build name in the format of: `accounts/{account}/apps/{app}/environments/{environment}/builds/{build}` - **envID** (string) - Environment ID - **name** (string) - Operation name in the format of: `accounts/{account}/apps/{app}/environments/{environment}/operations/{operation}` #### Response Example ```json { "done": false, "metadata": { "@type": "type.googleapis.com/google.cloud.headless.v1.EnvironmentOperationMetadata", "build": "accounts/myaccount/apps/myapps/environments/myenv/builds/build123", "envID": "myenv", "name": "accounts/myaccount/apps/myapps/environments/myenv/operations/op456" } } ``` ``` -------------------------------- ### Verify Local ISR Setup Source: https://developers.wpengine.com/docs/atlas/framework-guides/next-js/nextjs-isr-support Checks the runtime logs after starting the Next.js application locally to confirm that the Headless Platform's remote cache handler has been enabled, indicating successful ISR configuration. ```log Our Headless Platform remote cache handler enabled (local storage mode) ``` -------------------------------- ### Dockerfile Node Version Handling Note Source: https://developers.wpengine.com/docs/atlas/reference/cli/wpe/builds/get A note indicating that if a project's Node.js version is not supported by the build environment, it will be automatically upgraded to the closest supported version. Example shows 'Using Node version: 14'. ```text ----------generate dockerfile start---------- If project's Node version is not supported, Node will be upgraded to the project's closest supported version. Using Node version: 14 ----------generate dockerfile end------------ ``` -------------------------------- ### Schedule Webhook Rebuild with Cron (Bash) Source: https://developers.wpengine.com/docs/atlas/platform-guides/webhooks This example shows how to schedule a webhook rebuild using a cron job. It utilizes a curl command to send a POST request to the specified webhook URL, allowing for time-based rebuild patterns in your PHP application via WP Engine Alternate Cron. ```Bash curl -X POST https://js.wpengineapi.com/wh/v1/accounts/{your-account}/apps/{your-app}/environments/{your-env-id}/webhooks/webhook:{action}?token={your-token} ``` -------------------------------- ### Navigate to SvelteKit Project Directory Source: https://developers.wpengine.com/docs/atlas/framework-guides/sveltekit Command to change the current directory to the newly created SvelteKit project. This is a standard bash command. ```bash cd my-sveltekit-app ``` -------------------------------- ### Activate WP Engine Smart Search Plugin via WP-CLI Source: https://developers.wpengine.com/docs/wp-engine-ai-toolkit/plugin/multisite-setup This command network activates the WP Engine Smart Search plugin using the WP-CLI. Ensure you have SSH access and WP-CLI installed on your server. This is a prerequisite for configuring the plugin via the command line. ```bash wp plugin activate atlas-search --network ``` -------------------------------- ### WP Engine CLI: 'wpe apps create' Options Source: https://developers.wpengine.com/docs/atlas/reference/cli/wpe/apps/create This details the available command-line options for 'wpe apps create'. These flags allow users to specify environments, file paths for configuration, application names, and GitHub repositories. ```bash --environments, -e Environments in JSON format (use with -n, -r flags; surround value with single quotation marks) --filepath, -f Path to file with JSON of the app to create (use without -e, -n, -r flags) --help, -h Help for create --name, -n Assign a name to the app (optional use with -e, -r flags) --repo, -r GitHub repo associated with the app (use with -e, -n flags) ``` -------------------------------- ### Sync Data for WP Engine Smart Search Plugin via WP-CLI Source: https://developers.wpengine.com/docs/wp-engine-ai-toolkit/plugin/multisite-setup This command initiates a data synchronization for the WP Engine Smart Search plugin using WP-CLI. The `--reset` flag is optional and will delete the existing index before starting a full re-index. Use with caution as it can be time-consuming. ```bash wp wpe-smart-search sync-data --reset ``` -------------------------------- ### Apply Single Time Decay to Similarity Search Source: https://developers.wpengine.com/docs/wp-engine-ai-toolkit/vector-db/similarity-api This example demonstrates how to apply a single time decay function to boost recent documents in similarity search results. It targets the 'post_date' field, with decay starting after '7d', a scale of '30d', and a decay rate of 0.5. The output includes total results, document IDs, scores, and data. ```graphql query SimilarityWithTimeDecay { similarity( input: { nearest: { text: "eats carrots and is an animal", field: "post_content" } } options: { timeDecay: [ { field: "post_date", scale: "30d", decayRate: 0.5, offset: "7d" } ] } ) { total docs { id score data } } } ``` -------------------------------- ### Commit and Push Astro Configuration Changes Source: https://developers.wpengine.com/docs/atlas/framework-guides/astro Commands to stage, commit, and push changes made to the Astro configuration file after adding the Node adapter. ```bash # Stage all changed files $ git add -A # Commit the files to the current branch $ git commit -m "add node adapter to astro config" # Push changes to remote repository $ git push -u origin main ```