Cloud Services
Elasticsearch
Elasticsearch is a robust search engine designed for quick and efficient data retrieval in applications. It handles diverse data types, employs a distributed architecture, and offers a powerful query language for real-time search needs. Integration into your applications enhances search experiences, enabling developers to implement efficient full-text searches and complex queries. Elasticsearch's indexing capabilities make it valuable for applications such as monitoring systems, log analysis tools, and other scenarios requiring fast and relevant data access.
Below is a video for our OpenSearch functionality, which can be used as a reference when working with our Elasticsearch functions; they are largely the same.
Xano offers a few functions to make Elasticsearch requests simple.
Connect to Elasticsearch
Requires an Elasticsearch domain.
auth_type
Choose betweenBasic
,Bearer
orAPI Key
to set the type of authentication process to use.key_id
If usingBasic
, enter the username you wish to authenticate with. If usingBearer
, leave this blank. If usingAPI Key
, enter the API key identifier you wish to authenticate with.access_key
If usingBasic
, enter the API key secret you with to authenticate with. If usingBearer
, no access key is required. If usingAPI Key
, enter the value that corresponds with the key identifier you wish to authenticate with.base_url
Set to the domain endpoint where Elasticsearch is hosted.index
Enter the name of the Elasticsearch index to send request. Only applicable on Document and Query functions.
Elasticsearch Query Wizard Function
Use the query wizard to easily search documents stored in Elasticsearch.
Configure
See Connect to Elasticsearch for details on configuration.
Then, select a return_type
from the options below.
search
- Returns records that match querycount
- Returns number of total records matching query
Query
Query Wizard
Set filter criteria using the Xano query builder. The left input is the field to filter on. Then set the operator and value to evaluate. Optionally, add multiple conditions using AND / OR logic.
Select ‘Update Payload’ to ensure your changes are reflected in the query payload.
Output Options
These options can only be set on ‘search’ return type (not ‘count’).
Size: the number of results to return (useful for pagination)
From: the number to offset the results (useful for pagination)
Included Fields: field names to include in the results. Can be formatted as JSON array or comma separated string.
Sort: order to return results. Default is by Elasticsearch relevance score. Option to choose one or more fields to sort in ascending or descending order.
Payload (auto-generated)
The JSON sent as the payload to Elasticsearch. This is generated by the Query Wizard and Output Options sections. Useful for debugging.
Dynamic values (variables, inputs, etc.) are escaped using parentheses and use Xano expression syntax. These will be evaluated at the time of the request.
Changes made directly to the payload may be overwritten by other areas of the query wizard. If you already have a query payload you want to use, it is recommended to use the Elasticsearch Request function instead.
Elasticsearch: Document (CRUD) Function
Easily get, add, update, or remove documents from an Elasticsearch index.
Configure
See Connect to Elasticsearch for details on configuration.
Get Document
Set method of API request to GET
Specify doc_id
Create or Update Document
Set
method
toPOST
(create) orPUT
(update)Set
doc_id
(optional for POST)
Elasticsearch Request
Send any Elasticsearch API request using similar configuration methods as outlined in Connect to Elasticsearch.
Set the url
to use the desired endpoint of the request.
Set query
to the JSON payload if necessary.
OpenSearch
OpenSearch is an open-source search and analytics tool suite, derived from ElasticSearch, offered as a scalable and flexible solution by Amazon Web Services.
With OpenSearch, you can apply natural language processing, text analyzers, and built in machine learning to quickly return the most relevant data. This makes it a great tool for log analytics, application monitoring, and website searches.
Xano offers a few functions to make OpenSearch requests simple.
Connect to OpenSearch
Requires an OpenSearch Service domain hosted by AWS. Find AWS Documentation on Creating and managing Amazon OpenSearch Service domains.
auth_type
Choose betweenIAM
(AWS Identity and Access Management) andmaster
(basic auth from internal user database) to set the type of authentication process to use.key_id
If usingIAM
, enter the IAM key id you wish to authenticate with. If usingmaster
, enter the username you wish to authenticate with.access_key
If usingIAM
, enter the access key you wish to authenticate with. If usingmaster
, enter the password you wish to authenticate with.region
Only required forIAM
. Set to the configured OpenSearch region (example:us-east-2
).base_url
Set to the domain endpoint (IPv4) specified on AWS.index
Enter the name of the OpenSearch index to send request. Only applicable on Document and Query functions.
AWS OpenSearch Query Wizard Function
Use the query wizard to easily search documents stored in OpenSearch.
Configure
See Connect to OpenSearch for details on configuration.
Then, select a return_type
from the options below.
search -
Returns records that match querycount
- Returns number of total records matching query
Query
Query Wizard
Set filter criteria using the Xano query builder. The left input is the field to filter on. Then set the operator and value to evaluate. Optionally, add multiple conditions using AND / OR logic.
Select ‘Update Payload’ to ensure your changes are reflected in the query payload.
Output Options
These options can only be set on ‘search’ return type (not ‘count’).
Size: the number of results to return (useful for pagination)
From: the number to offset the results (useful for pagination)
Included Fields: field names to include in the results. Can be formatted as JSON array or comma separated string.
Sort: order to return results. Default is by OpenSearch relevance score. Option to choose one or more fields to sort in ascending or descending order.
Payload (auto-generated)
The JSON sent as the payload to OpenSearch. This is generated by the Query Wizard and Output Options sections. Useful for debugging.
Dynamic values (variables, inputs, etc.) are escaped using parentheses and use Xano expression syntax. These will be evaluated at the time of the request.
Changes made directly to the payload may be overwritten by other areas of the query wizard. If you already have a query payload you want to use, it is recommended to use the OpenSearch Request function instead.
AWS OpenSearch: Document (CRUD) Function
Easily get, add, update, or remove documents from an OpenSearch index.
Configure
See Connect to OpenSearch for details on configuration.
Get Document
Set method of API request to GET
Specify doc_id
Create or Update Document
Set
method
toPOST
(create) orPUT
(update)Set
doc_id
(optional for POST)Set document payload. Click ‘Use Index Schema’ if you want to import the schema (mapping) directly from the OpenSearch index set under Configure tab. This will use the credentials provided to make a request to OpenSearch on your behalf to get the mapping.
AWS OpenSearch Request
Send any OpenSearch API request using similar configuration methods as outlined in Connect to OpenSearch.
Set the url
to use the desired endpoint of the request.
Set query
to the JSON payload if necessary.
Google Cloud Storage
Manage Google Cloud Storage buckets directly in the Xano function stack.
Google Service Account
You need to set up a Google Service Account in the Google Cloud Console.
Navigate to IAM & Admin and select Service Accounts.
Select + Create Service Account.
Roles
Be sure to include the following Roles for the Service Account:
Service Account User
Storage Admin
Storage Object Admin
Once the Service Account is created, select actions and Manage keys.
Then add a new key and select the JSON option.
Google will provide a JSON file for download. Open the file and copy the JSON key. Paste this into your Xano workspace either as an Environment Variable or as a variable in the function stack that you are using the Google Cloud Storage functions.
The JSON key must be entered as a text string. Do not import the key as JSON when adding it to Xano.
List Directory
List the contents of a Google Cloud Storage Bucket.
Service Account - the JSON key, stored as text, from your Google Service Account
Bucket - the name of the Bucket you wish to access.
Path - the path you wish to see the contents of.
Signed URL
Generate a signed URL to provide limited permissions. These can be used with a TTL (time to live) similar to an expiring token.
Service Account - the JSON key, stored as text, from your Google Service Account
Bucket - the name of the Bucket you wish to access.
filePath - the path of the file you wish to generate the URL for.
Method - the HTTP method (GET or POST)
TTL - time to live, in seconds. (How long until the URL expires).
Upload a File
Upload a File to the specific Google Cloud Storage bucket.
Service Account - the JSON key, stored as text, from your Google Service Account
Bucket - the name of the Bucket you upload a file to.
filePath - the path and name of the file you wish to store in the bucket. For example "files/image1" will upload the image in the files folder and name it image1.
File - the file being uploaded. This should come from a file resource input or a file resource variable.
Delete File
Delete a specific file from a Bucket.
Service Account - the JSON key, stored as text, from your Google Service Account
Bucket - the name of the Bucket that contains the file.
filePath - the path of the file you wish to delete from the Bucket.
Create Variable From File Resource
Return the file resource as a variable in Xano, including the raw image. This can be used, for example, to send to another service if file transfer is needed.
Service Account - the JSON key, stored as text, from your Google Service Account
Bucket - the name of the Bucket that contains the file.
filePath - the path of the file you wish to create a variable of.
Example - Using the Variable Created from File Resource
Turn your API endpoint into a redirect to the file by returning the data field from the return variable and setting a custom header of Content-Type with the mime of the file resource.
Here's an example return of Create Variable from File Resource:
If we return the raw image (data) and use a Set Header function to define Content-Type
the mime (in this example image/png
). We can have our endpoint URL redirect to the file.
Amazon S3
Access Key and Secret Access Key
From your AWS Developer Console, navigate to Security Credentials.
Scroll down to Access Keys and select Create access key unless you have an access key and secret already generated.
Select Command Line Interface (CLI) as the use case and choose next, optionally add a description, then create the access key.
Store the Access key and Secret access key in a safe place. It's recommended to save these in your Xano workspace as Environment Variables as they will be used in the Amazon S3 Cloud Storage Functions.
Bucket and Region
The s3 bucket name and region will also be required when calling the Amazon s3 Cloud Storage Functions.
When navigating to your s3 buckets, the bucket name can be found under name. The region is under region but only requires the identifier. For example, in the below image the bucket name is xano-s3-test and the region is us-west-2.
Amazon S3: List Directory
Lists the directory details of the specific Amazon s3 bucket.
Bucket - The name of the s3 bucket you want to get the details of.
Region - The region of the bucket.
Key - The access key
Secret - The secret access key
Next_page_token - optional. The next page token is provided in the response if there is a next page, use this value to get the next page of items. S3 buckets limit 1,000 items per page.
Amazon S3: Signed URL
Creates a signed URL of the file to be shared with an expiration.
Bucket - The name of the s3 bucket you want to get the details of.
Region - The region of the bucket.
Key - The access key
Secret - The secret access key
File_key - The file key of the file. This can be found in the s3 bucket when selecting the file and finding Key. Additionally, the Key is listed in the payload for List Directory.
TTL - Time to live. How long, in seconds, the signed URL is viewable until it expires.
Amazon S3: Upload a File
Upload a file to a specified Amazon S3 Bucket
Bucket - The name of the s3 bucket you want to get the details of.
Region - The region of the bucket.
Key - The access key
Secret - The secret access key
File_key - Optionally define the file key. If nothing is defined, one will be automatically assigned by Amazon S3.
File - The file being uploaded. This must come from a file resource input or file resource variable.
Amazon S3: Delete File
Delete a file from a specified S3 Bucket.
Bucket - The name of the s3 bucket you want to get the details of.
Region - The region of the bucket.
Key - The access key
Secret - The secret access key
File_key - The file key of the file you wish to delete.
Amazon S3: Create Var From File Resource
Return the file resource as a variable in Xano, including the raw image. This can be used, for example, to send to another service if file transfer is needed.
Bucket - The name of the s3 bucket you want to get the details of.
Region - The region of the bucket.
Key - The access key
Secret - The secret access key
File_key - The file key of the file you wish to return the file resource as a variable.
The result, shown on the right-hand side of the above image returns an object with the file name, size, mime type, and raw image represented in the path data.
Check out the example above to return the image through an API request.
Microsoft Azure Blob Storage
Manage storage containers from your Microsoft Azure account directly from the Xano function stack.
Setup
Please ensure you have a Microsoft Azure account. If you don't yet have an account sign up to Microsoft Azure and navigate to the Azure portal.
Create a storage account
A storage account is required to store files on Azure. First, select Create a resource from the portal homepage.
Navigate to storage and select Create under storage account.
Fill out the required information in Basics, if you don't already have a resource group, create a new one.
Configure any additional settings and create the storage account once you're ready.
Create a container
Once the resource is deployed, navigate to containers and create a new container.
Access key
After creating a container, you need to retrieve your account access key to use the Azure functions in Xano.
Find Access keys under Security + Networking on the left navigation bar. Select Show next to Key under key1. Copy the key and store it as an Environment Variable in Xano.
Do not share your access key. It is recommended to store your access key as an Environment Variable in Xano for safe keeping.
List Directory
List directory will list the blobs, properties, and metadata in a container or at a specified path within the container.
account_name - Azure storage account name.
account_key - Azure Access Key.
conatiner_name - Container name within Azure storage account.
path - (Optional) Use this to specify a specific blob or folder within a container.
Signed URL
Creates a signed URL for a file with a specified time to live (TTL) or expiration.
account_name - Azure storage account name.
account_key - Azure Access Key.
conatiner_name - Container name within Azure storage account.
path - The path of the file to create a signed URL for.
ttl - Time to Live (in seconds); how long the signed URL is accessible.
Upload a File
Upload a file to an Azure blob container.
account_name - Azure storage account name.
account_key - Azure Access Key.
conatiner_name - Container name within Azure storage account.
filePath - The path name for the file being uploaded.
file - The file being uploaded. This must come from a file resource.
metadata - (Optional). Optionally include additional metadata with the file stored in object format.
Delete a File
Delete a file from an Azure blob container.
account_name - Azure storage account name.
account_key - Azure Access Key.
conatiner_name - Container name within Azure storage account.
filePath - The path name for the file being deleted.
Create Variable From File Resource
Create a variable from a file resource in Azure to use it in the Xano Function Stack.
account_name - Azure storage account name.
account_key - Azure Access Key.
conatiner_name - Container name within Azure storage account.
filePath - The path name for the file being created as a variable.
Check out the example above of leveraging the Variable from File Resource in the Function Stack.
Get File Metadata
Get the metadata of a file from an Azure blob container.
account_name - Azure storage account name.
account_key - Azure Access Key.
conatiner_name - Container name within Azure storage account.
filePath - The path name for the file to retrieve the metadata from.
Last updated