### Start the Search UI
Source: https://www.addsearch.com/docs/implementing-ai-answers
Call the `start()` method on the `addSearchUi` instance to render the configured components into their respective container elements.
```javascript
addSearchUi.start();
```
--------------------------------
### Configure UI Components and Start Search
Source: https://www.addsearch.com/docs/search-ui/search-ui-library-getting-started
Define search field, results, and pagination components with container IDs and start the UI instance.
```javascript
// UI components
searchui.searchField({
containerId: 'searchfield-container',
placeholder: 'Keyword..',
button: 'Search',
searchAsYouType: true
});
searchui.searchResults({
containerId: 'results-container'
});
searchui.pagination({
containerId: 'pagination-container'
});
// Start after all components are added
searchui.start();
```
--------------------------------
### Full document schema example
Source: https://www.addsearch.com/docs/api/indexing-update
An example showing the structure of a document including standard fields and custom fields.
```json
{
"id": "123",
"thumbnail_external_src": "https://www.example.com/thumbnail-image.jpg",
"url": "https://www.example.com/page.html",
"language": "en",
"title": "An example article title",
"main_content": "The text content of the article. The automatic highlight in search results will only be generated from the content of this field.",
"custom_fields": {
"image_url": "https://www.example.com/page.png",
"article_categories": ["Block post", "Article"]
}
}
```
--------------------------------
### Complete AddSearch Integration Example
Source: https://www.addsearch.com/docs/implementing-ai-answers
This is a full HTML example demonstrating the integration of AddSearch JavaScript client and Search UI, including script includes, container divs, and initialization code for search field and AI answers.
```html
AddSearch AI Answers
```
--------------------------------
### GA4 Installation Snippet
Source: https://www.addsearch.com/docs/analytics/google-analytics-integration
This is the GA4 installation snippet to be used when serving analytics directly through GA4. Ensure GA integration is enabled in your AddSearch installation.
```javascript
```
--------------------------------
### Filter Parameter Examples
Source: https://www.addsearch.com/docs/api/search-results
Examples demonstrating how to use the 'filter' query parameter to refine search results based on various criteria.
```APIDOC
## Filter Parameter Examples
### Example 1: Price Range
Return results with `custom_fields.price` between 10000 and 20000.
**Filter JSON:**
```json
{
"range": {
"custom_fields.price": {
"gt": "10000",
"lt": "20000"
}
}
}
```
**URL-encoded Filter:**
```
filter%3D%7B%0A%20%20%20%20%22range%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%22custom_fields.price%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%22gt%22%3A%20%2210000%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22lt%22%3A%20%2220000%22%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%7D%0A
```
### Example 2: Multiple Criteria (AND, NOT, Range)
Return results where brand is apple, color is not white, and price is between 200 and 500.
**Filter JSON:**
```json
{
"and": [
{ "custom_fields.brand": "apple" },
{ "not": { "custom_fields.color": "white" } },
{ "range": { "custom_fields.price": { "gt": 200, "lt": 500 } } }
]
}
```
**URL-encoded Filter:**
```
filter%3D%7B%0A%20%20%20%20%27and%27%3A%20%5B%0A%20%20%20%20%20%20%20%20%7B%20%27custom_fields.brand%27%3A%20%27apple%27%20%7D%2C%0A%20%20%20%20%20%20%20%20%7B%20%27not%27%3A%20%7B%20%27custom_fields.color%27%3A%20%27white%27%20%7D%20%7D%2C%0A%20%20%20%20%20%20%20%20%7B%20%27range%27%3A%20%7B%20%27custom_fields.price%27%3A%20%7B%20%27gt%27%3A%20200%2C%20%27lt%27%3A%20500%20%7D%20%7D%20%7D%0A%20%20%20%20%5D%0A%7D%3B
```
### Example 3: Category Matching
Return results from `example.com` and `/blog/`.
**Filter JSON:**
```json
{
"and": [
{ "category": "0xexample.com" },
{ "category": "1xblog" }
]
}
```
**URL-encoded Filter:**
```
filter%3D%7B%0A%20%22and%22%3A%20%5B%0A%20%20%20%7B%22category%22%3A%220xexample.com%22%7D%2C%0A%20%20%20%7B%22category%22%3A%221xblog%22%7D%0A%20%5D%0A%7D%0A
```
### Example 4: Case-Insensitive Manufacturer Match (OR)
Return results against custom fields manufacturer values nokia, or Nokia, or NOKIA.
**Filter JSON:**
```json
{
"and": [
{
"or": [
{ "custom_fields.manufacturer": "nokia" },
{ "custom_fields.manufacturer": "Nokia" },
{ "custom_fields.manufacturer": "NOKIA" }
]
}
]
}
```
**URL-encoded Filter:**
```
filter%3D%7B%22and%22%3A%5B%7B%22or%22%3A%5B%7B%22custom_fields.manufacturer%22%3A%20%22nokia%22%7D%2C%7B%22custom_fields.manufacturer%22%3A%20%22Nokia%22%7D%2C%7B%22custom_fields.manufacturer%22%3A%20%22NOKIA%22%7D%5D%7D%5D%7D
```
```
--------------------------------
### Install AddSearch WordPress Plugin
Source: https://www.addsearch.com/docs/installation/wordpress
Follow these steps to install the AddSearch plugin from the WordPress plugin directory. Ensure you have an AddSearch account and a crawling index set up beforehand.
```bash
1. Log in to your WordPress account
2. Click the **Plugins** link
3. On the Plugins page, click the **Add New** button
4. On the Add Plugins page, search with the keyword **AddSearch** to find the AddSearch plugin
5. Click the **Install Now** button to install the AddSearch plugin
6. After the installation, activate the plugin by clicking the **Activate** button
```
--------------------------------
### RSS Feed Format Examples
Source: https://www.addsearch.com/docs/indexing/real-time
Examples of valid Atom 1.0 and RSS 2.0 feed structures for use with AddSearch.
```xml
Example Feedhttps://www.addsearch.com/feed2019-05-29T14:09:42ZProduct Updateshttps://www.addsearch.com/product/updates/2017-05-22T09:00:00Z2019-05-29T11:12:39Z
```
```xml
A simple RSS feed
https://www.addsearch.com/feed/
AddSearch example feedMon, 17 Jun 2019 01:45:45 GMTProduct Updates
https://www.addsearch.com/product/updates/
Sun, 16 Jun 2019 13:00:00 GMT
```
--------------------------------
### Add Search API Response Example
Source: https://www.addsearch.com/docs/api/crawl-url
This is an example of the JSON response received after a successful Add Search API call, indicating the request has been scheduled.
```json
{
"message": "Scheduled",
"docId": "doc id"
}
```
--------------------------------
### Filter by Domain
Source: https://www.addsearch.com/docs/indexing/search-filtering
Use '0x' prefix to filter results from a specific domain. Example includes www.example.com.
```json
{ "category": "0xwww.example.com" }
```
--------------------------------
### Configure the AddSearch installation script
Source: https://www.addsearch.com/docs/installation/configurable-srp
Use the window.addsearch_settings object to define search behavior and include the AddSearch UI script.
```html
```
--------------------------------
### Configure Search UI Components
Source: https://www.addsearch.com/docs/search-ui/autocomplete-suggestions
Registers search field and autocomplete components to the UI instance and starts the library.
```javascript
// Add components
searchui.searchField({
containerId: 'searchfield',
placeholder: 'Keyword..'
});
// Don't forget to set up Search Suggestions on AddSearch Dashboard first
searchui.autocomplete({
containerId: 'autocomplete',
sources: [
{
type: AddSearchUI.AUTOCOMPLETE_TYPE.SUGGESTIONS
}
]
});
// All components added. Start
searchui.start();
```
--------------------------------
### GET /v1/suggest/{site_key}
Source: https://www.addsearch.com/docs/api/search-suggestions
Retrieves a list of search suggestions for a given search term.
```APIDOC
## GET /v1/suggest/{site_key}
### Description
Retrieves search suggestions for a specific site based on the provided term.
### Method
GET
### Endpoint
https://api.addsearch.com/v1/suggest/{site_key}
### Parameters
#### Path Parameters
- **site_key** (string) - Required - The unique site identifier.
#### Query Parameters
- **term** (string) - Required - The search term to get suggestions for.
- **size** (int) - Optional - The number of search suggestions to return (default: 10).
- **language** (string) - Optional - Limit suggestions to a certain language using ISO 639-1 two-letter code.
### Request Example
https://api.addsearch.com/v1/suggest/1bed1ffde465fddba2a53ad3ce69e6c2?term=api
### Response
#### Success Response (200)
- **suggestions** (array) - List of suggestion objects containing the value.
#### Response Example
{
"suggestions": [
{ "value": "api" },
{ "value": "api call" },
{ "value": "rest api" },
{ "value": "search api" }
]
}
```
--------------------------------
### Standard AddSearch Widget Configuration
Source: https://www.addsearch.com/docs/installation/configurable-widget
The default installation script structure for the AddSearch widget. Replace the #### placeholder with your actual site key.
```html
```
--------------------------------
### Filter by Specific URL Path
Source: https://www.addsearch.com/docs/indexing/search-filtering
Combine domain and path prefixes to filter for a specific URL path. Example includes www.example.com/manufacturers/apple/.
```json
{ "and": [ { "category": "0xwww.example.com" }, { "category": "1xmanufacturers" }, { "category": "2xapple" } ] }
```
--------------------------------
### Filter by First Path Segment
Source: https://www.addsearch.com/docs/indexing/search-filtering
Use '1x' prefix to filter results from the first path segment. Example includes '/blog/'.
```json
{ "category": "1xblog" }
```
--------------------------------
### API Search Request
Source: https://www.addsearch.com/docs/api/search-results
Example of a GET request to the AddSearch API.
```http
https://api.addsearch.com/v1/search/cfa10522e4ae6987c390ab72e9393908?term=rest+api
```
--------------------------------
### Install AddSearch Recommend Widget
Source: https://www.addsearch.com/docs/installing-addsearch-recommend
Paste this script element into your website's template or source code where the recommendations should appear. Ensure the key and block_id parameters match your specific widget configuration.
```html
```
--------------------------------
### Initialize AddSearch Client and UI Instance
Source: https://www.addsearch.com/docs/search-ui/search-ui-library-getting-started
Create the AddSearch client using a site key and initialize the Search UI library instance.
```javascript
// AddSearch JS client with an example index. Get your own SITEKEY by signing up at www.addsearch.com
var client = new AddSearchClient('2c32bf3eb06b30af5f8208481aea3e8b');
// Search UI instance
var searchui = new AddSearchUI(client);
```
--------------------------------
### AddSearch Widget Installation Script
Source: https://www.addsearch.com/docs/installation/hubspot
This script initializes the AddSearch widget settings and loads the UI library. Replace 'xxxxxx' with your actual site key.
```html
```
--------------------------------
### Initialize AddSearch Client and UI Instance
Source: https://www.addsearch.com/docs/search-ui/autocomplete-suggestions
Creates the Javascript client using a site key and initializes the Search UI library with configuration parameters.
```javascript
// AddSearch JS client with an example index. Get your own SITEKEY by signing up at www.addsearch.com
var client = new AddSearchClient('2c32bf3eb06b30af5f8208481aea3e8b');
var conf = {
searchResultsPageUrl: '/search',
updateBrowserHistory: false
};
// Search UI instance
var searchui = new AddSearchUI(client, conf);
```
--------------------------------
### Initialize AddSearch Client and Search UI
Source: https://www.addsearch.com/docs/implementing-ai-answers
Instantiate the AddSearch JavaScript client and the Search UI library. Ensure you replace 'YOUR_PUBLIC_SITE_KEY' with your actual site key. The `hasAiAnswers: true` option enables AI answers.
```javascript
const addSearchClient = new AddSearchClient('YOUR_PUBLIC_SITE_KEY');
const addSearchUi = new AddSearchUI(addSearchClient, { hasAiAnswers: true });
```
--------------------------------
### Include AddSearch Dependencies
Source: https://www.addsearch.com/docs/implementing-ai-answers
Load the required JavaScript client, Search UI library, and CSS stylesheet in your HTML document.
```html
```
--------------------------------
### Get Document Contents
Source: https://www.addsearch.com/docs/api/indexing-overview
Retrieves the content of a specific document from the index.
```APIDOC
## GET /v1/documents/{id}
### Description
Retrieves the content of a specific document from the index.
### Method
GET
### Endpoint
/v1/documents/{id}
### Parameters
#### Path Parameters
- **id** (string) - Required - The unique identifier of the document to retrieve.
```
--------------------------------
### Include Search UI Dependencies
Source: https://www.addsearch.com/docs/search-ui/search-ui-library-getting-started
Add the required JavaScript client, Search UI library, and CSS stylesheet to your HTML page.
```html
```
--------------------------------
### GET /websites/addsearch
Source: https://www.addsearch.com/docs/api/indexing-get
Describes the structure of a document object returned by the Addsearch API.
```APIDOC
## GET /websites/addsearch
### Description
Retrieves the structure of a document object, including standard fields and custom field mappings.
### Response
#### Success Response (200)
- **id** (string) - Document's id, URL encoded as md5 hash.
- **thumbnail_external_src** (string) - A URL of an image used as a thumbnail for the document by default.
- **custom_fields** (map) - A map of custom fields key-value pairs. Supported data-types: text, integer, and double.
#### Response Example
{
"id": "8700a03070a37982924597d6baa87be7",
"thumbnail_external_src": "https://www.example.com/thumbnail-image.jpg",
"custom_fields": {
"title": "Example product",
"description": "Description for example product",
"price_cents": 599,
"average_customer_rating": 4.5
}
}
```
--------------------------------
### Perform a search query
Source: https://www.addsearch.com/docs/api/getting-started-with-the-indexing-api
Use a GET request to search the index for a specific term.
```curl
curl --request GET \
--url 'https://api.addsearch.com/v1/search/{your index public key}/?term=test'
```
--------------------------------
### Example of Categories Parameter
Source: https://www.addsearch.com/docs/api/search-results
Demonstrates how to use the 'categories' parameter to filter search results by domain, URL path, or file type. The parameter requires a specific format for each type of category.
```URL
&categories=0xwww.example.com
```
```URL
&categories=1xnews
```
```URL
&categories=doctype_pdf
```
--------------------------------
### GET /websites/addsearch
Source: https://www.addsearch.com/docs/api/document-status
Retrieves the status and metadata for a specific document in the Addsearch index. Authentication is required.
```APIDOC
## GET /websites/addsearch
### Description
Retrieves the status and metadata for a specific document in the Addsearch index. Authentication is required.
### Method
GET
### Endpoint
/websites/addsearch
### Parameters
#### Query Parameters
- **indexPublicKey** (string) - Required - The public site key for the index.
- **docId** (string) - Required - The document's ID, which is an MD5 hash of the URL.
### Response
#### Success Response (200)
- **indexPublicKey** (string) - The public site key.
- **docId** (string) - Document's id (URL encoded as md5 hash).
- **status** (string) - Document's status. Possible values are “INDEXED”, “EXCLUDED”, “PENDING”, “ERROR”, “UNKNOWN”.
- **statusInfo** (string) - Document's status info explained in detail.
- **lastFetched** (string) - The time when the document was last updated. The format is YYYY-MM-DDT00:00:00.000Z.
- **duplicateOf** (object) - The URL of indexed document with the same content. Null if missing.
- **href** (string) - URL to the duplicate document.
- **content** (object) - Document's content. Null if missing.
- **href** (string) - URL to the document's content.
#### Response Example
```json
{
"indexPublicKey": "index public key",
"docId": "md5 of url",
"status": "INDEXED",
"statusInfo": "Duplicate of another-doc-id",
"lastFetched": "2015-01-13T13:43:01.000Z",
"duplicateOf": {
"href": "https://api.addsearch.com/v1/indices/{index public key}/documents/{doc id}"
},
"content": {
"href": "https://api.addsearch.com/v1/indices/{index public key}/documents/{doc id}/content"
}
}
```
```
--------------------------------
### Exclude Language
Source: https://www.addsearch.com/docs/indexing/search-filtering
Use 'not' to exclude documents in a specific language. Example excludes English ('en').
```json
{ "not": { "language": "en" } }
```
--------------------------------
### Configure Search Suggestions via Script
Source: https://www.addsearch.com/docs/search-ui/implementing-search-suggestions
Enable search suggestions by setting the show_search_suggestions property to true within the addsearch_settings object.
```html
```
--------------------------------
### Retrieve document content
Source: https://www.addsearch.com/docs/api/getting-started-with-the-indexing-api
Use a GET request to fetch the current content and metadata of a specific document.
```curl
curl --request GET \
--url https://api.addsearch.com/v2/indices/{your index public key}/documents/test \
--user '{your index public key}:{your index secret key}'
```
--------------------------------
### AddSearch Widget Configuration Script
Source: https://www.addsearch.com/docs/installation/install-on-optimizely-episerver
This script initializes the AddSearch widget with specific settings and loads the UI library. Replace 'xxxxxx' in the script source URL with your actual site key.
```html
```
--------------------------------
### Filter by Custom Field (Manufacturer)
Source: https://www.addsearch.com/docs/indexing/search-filtering
Filter results based on a custom field, such as 'manufacturer'. Example filters for 'apple'.
```json
{ "custom_fields.manufacturer": "apple" }
```