Vantage Documentation: searchRecords
Purpose
The searchRecords logic in Vantage is designed to facilitate the retrieval of records from the designated application, specifically in the contacts app. It allows users to search for specific records using a query string and can return a limited number of results based on predefined criteria. The functionality is essential for businesses or applications needing quick access to contact data filtered by user-defined searches.
Settings
The searchRecords logic has two primary settings that dictate its operation. Below is an in-depth description of each setting:
1. Query
- Input Type: String
- Description: The
querysetting represents the search term input by the user to filter records. This term is utilized to match against searchable fields in the contact records.- Behavior: The effectiveness of this setting hinges on the data structure of the records. A more specific query will yield narrower results, while a broader query may return more matches.
- Default Value: An empty string (
''). If no value is provided, the function will default to searching with an empty query, potentially returning all records depending on other applied constraints.
2. Limit
- Input Type: Number
- Description: The
limitsetting defines the maximum number of records to be returned by the search. This is essential for performance optimization, particularly in environments dealing with large datasets.- Behavior: Altering this value will affect the number of results returned:
- A lower limit will provide a smaller subset of results, which can improve response times but may omit records of interest.
- A higher limit may increase response times but ensures more comprehensive search results are returned to the user.
- Behavior: Altering this value will affect the number of results returned:
- Default Value: 100. This means if no limit is specified, the search will return up to 100 records by default.
How It Works
The searchRecords function operates through the following sequence of steps:
- Context Handling: It retrieves the app type and user context (like
clientIdanduserId). - Input and Configuration Resolution: It checks for
queryinput—if not provided, it falls back on the configured value. It also determines thelimit, defaulting to 100 if not specified. - Error Handling: If
clientIdis not available in the context, it returns an error indicating the missingclientId. - Schema Retrieval: It retrieves the schema of the identified app type and determines which fields are searchable.
- Data Adapter Creation: The function creates a data adapter based on the storage provider specified in the application configuration.
- Record Searching: It invokes the
searchRecordsmethod of the adapter, passing the query and constraints defined by the schema. - Output Formatting: Finally, it returns the matched records, sliced according to the
limit. If any errors arise during execution, they are captured and returned.
Input Expectations
To function correctly, searchRecords expects the following input:
- Inputs:
inputs.query: A string containing the search term to locate relevant records.
- Configuration:
config.query: An optional string that can override the input query if needed.config.limit: An optional numeric value that specifies how many records to return.
Use Cases & Examples
Use Cases
-
Customer Support: A support team can quickly search through customer contact records based on queries related to customer names or issues, improving response time and service efficiency.
-
Marketing Campaigns: Marketing teams can search for specific audience segments by querying contact records based on interests or demographics, allowing targeted outreach.
-
Data Cleansing: Data analysts can search for specific records that might require verification or updates, optimizing the quality of contact data stored within the system.
Example Configuration
Use Case: A customer service representative needs to find all contacts related to a specific issue for follow-up.
Configuration:
{
"inputs": {
"query": "order issue"
},
"config": {
"limit": 50
},
"context": {
"nodeType": "contacts/searchRecords",
"clientId": "12345",
"userId": "67890"
}
}Expected Behavior: This configuration sets the query for searching records to "order issue" and limits the results to a maximum of 50 records. The representative will efficiently retrieve relevant contacts to address the issue, ensuring a prompt service response.
Billing Impact
While the implementation of the searchRecords logic itself does not directly contribute to billing, the results returned and the query processing capabilities may impact overall usage metrics, which can be part of the billing model. High-frequency use of this logic in a large dataset scenario may lead to increased processing costs, particularly if many requests are made in a short time. Monitoring the frequency of such queries is advisable for efficient cost management.