### Get Index Settings Request Example
Source: https://zincsearch-docs.zinc.dev/api/index/get-settings
Example of an HTTP GET request to retrieve index settings.
```http
GET http://localhost:4080/api/myindex/_settings
```
--------------------------------
### Get Index Settings Response Example
Source: https://zincsearch-docs.zinc.dev/api/index/get-settings
Sample JSON response showing the settings for an index, including analysis configuration.
```json
{
"myindex": {
"settings": {
"analysis": {
"analyzer": {
"default": {
"type": "standard"
}
}
}
}
}
}
```
--------------------------------
### Get Index Mapping Example
Source: https://zincsearch-docs.zinc.dev/api/index/get-mapping
This example shows how to retrieve the mapping for an index named 'myindex' using an HTTP GET request.
```http
GET http://localhost:4080/api/myindex/_mapping
```
--------------------------------
### Golang Search Example
Source: https://zincsearch-docs.zinc.dev/api/search/search
Provides a Golang example for performing a search request. It demonstrates setting up the request, including basic authentication and headers, and handling the response.
```go
package main
import (
"fmt"
"io"
"log"
"net/http"
"strings"
)
func main() {
query := `{
"search_type": "match",
"query":
{
"term": "DEMTSCHENKO",
"start_time": "2021-06-02T14:28:31.894Z",
"end_time": "2021-12-02T15:28:31.894Z"
},
"from": 0,
"max_results": 20,
"_source": []
}`
req, err := http.NewRequest("POST", "http://localhost:4080/api/games3/_search", strings.NewReader(query))
if err != nil {
log.Fatal(err)
}
req.SetBasicAuth("admin", "Complexpass#123")
req.Header.Set("Content-Type", "application/json")
req.Header.Set("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36")
resp, err := http.DefaultClient.Do(req)
if err != nil {
log.Fatal(err)
}
defer resp.Body.Close()
log.Println(resp.StatusCode)
body, err := io.ReadAll(resp.Body)
if err != nil {
log.Fatal(err)
}
fmt.Println(string(body))
}
```
--------------------------------
### Kubernetes Helm Installation
Source: https://zincsearch-docs.zinc.dev/installation
Create a namespace and install the ZincSearch Helm chart. Update values in values.yaml as needed.
```bash
kubectl create ns zincsearch
helm install zincsearch helm/zincsearch -n zincsearch
```
--------------------------------
### Get Index Settings Example
Source: https://zincsearch-docs.zinc.dev/api-es-compatible/index/get-settings
Use this endpoint to retrieve the configuration settings for a given index. The response includes details about the index's analysis settings.
```http
GET http://localhost:4080/es/myindex/_settings
```
```json
{
"myindex": {
"settings": {
"analysis": {
"analyzer": {
"default": {
"type": "standard"
}
}
}
}
}
}
```
--------------------------------
### macOS/Linux Homebrew Installation and Execution
Source: https://zincsearch-docs.zinc.dev/installation
Tap the ZincSearch repository, install the package using Homebrew, create a data directory, and run ZincSearch with environment variables.
```bash
brew tap zinclabs/tap
brew install zinclabs/tap/zincsearch
mkdir data
ZINC_FIRST_ADMIN_USER=admin ZINC_FIRST_ADMIN_PASSWORD=Complexpass#123 zincsearch
```
--------------------------------
### List All Users Response Example
Source: https://zincsearch-docs.zinc.dev/api/user/list
This is an example of the JSON response when listing all users. It shows the structure of the response, including metadata and the list of user hits.
```json
{
"took": 0,
"timed_out": false,
"_shards": {
"total": 0,
"successful": 0,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 1
},
"max_score": 0,
"hits": [
{
"_index": "admin",
"_type": "admin",
"_id": "admin",
"_score": 0,
"@timestamp": "2022-05-31T14:27:19.285611+08:00",
"_source": {
"_id": "admin",
"name": "admin",
"role": "admin",
"created_at": "2022-05-31T14:27:19.285611+08:00",
"updated_at": "2022-05-31T14:27:19.285611+08:00"
}
}
]
},
"error": ""
}
```
--------------------------------
### Example Document Structure
Source: https://zincsearch-docs.zinc.dev/concepts
This is an example of a JSON document that can be indexed by ZincSearch.
```json
{
"message":"Prabhat Sharma is a cool guy to hang with."
}
```
--------------------------------
### Get Index Mapping Example
Source: https://zincsearch-docs.zinc.dev/api-es-compatible/index/get-mapping
Use this endpoint to retrieve the mapping of an index. This is useful for understanding the structure and data types of fields within your index.
```http
GET http://localhost:4080/es/olympics/_mapping
```
--------------------------------
### Get Index Template Response
Source: https://zincsearch-docs.zinc.dev/api-es-compatible/index/get-template
This is an example of the JSON response when retrieving an index template. It shows the structure of index patterns, priority, and the template's settings and mappings.
```json
{
"index_patterns": ["game-*"],
"priority": 199,
"template": {
"settings": {
"analysis": {
"analyzer": {
"default": {
"type": "standard"
}
}
}
},
"mappings": {
"properties": {
"content": {
"type": "text",
"index": true,
"store": true,
"sortable": false,
"aggregatable": false,
"highlightable": true
}
}
}
}
}
```
--------------------------------
### Bulk Document Upload Example
Source: https://zincsearch-docs.zinc.dev/api/document/bulk
This example demonstrates how to upload multiple documents in a single request using the newline-delimited JSON (ndjson) format. Each document operation is preceded by an action line specifying the index and optionally an ID.
```json
{ "index" : { "_index" : "olympics" } }
{"Year": 1896, "City": "Athens", "Sport": "Aquatics", "Discipline": "Swimming", "Athlete": "HAJOS, Alfred", "Country": "HUN", "Gender": "Men", "Event": "100M Freestyle", "Medal": "Gold", "Season": "summer"}
{ "index" : { "_index" : "olympics" } }
{"Year": 1896, "City": "Athens", "Sport": "Aquatics", "Discipline": "Swimming", "Athlete": "HERSCHMANN, Otto", "Country": "AUT", "Gender": "Men", "Event": "100M Freestyle", "Medal": "Silver", "Season": "summer"}
{ "index" : { "_index" : "olympics" } }
{"Year": 1896, "City": "Athens", "Sport": "Aquatics", "Discipline": "Swimming", "Athlete": "DRIVAS, Dimitrios", "Country": "GRE", "Gender": "Men", "Event": "100M Freestyle For Sailors", "Medal": "Bronze", "Season": "summer"}
{ "index" : { "_index" : "olympics" } }
{"Year": 1896, "City": "Athens", "Sport": "Aquatics", "Discipline": "Swimming", "Athlete": "MALOKINIS, Ioannis", "Country": "GRE", "Gender": "Men", "Event": "100M Freestyle For Sailors", "Medal": "Gold", "Season": "summer"}
{ "index" : { "_index" : "olympics" } }
{"Year": 1896, "City": "Athens", "Sport": "Aquatics", "Discipline": "Swimming", "Athlete": "CHASAPIS, Spiridon", "Country": "GRE", "Gender": "Men", "Event": "100M Freestyle For Sailors", "Medal": "Silver", "Season": "summer"}
```
--------------------------------
### Analyze with Tokenizer and Filter
Source: https://zincsearch-docs.zinc.dev/api/index/analyze
This example shows how to configure both a tokenizer and a token filter for text analysis.
```APIDOC
## POST /api/_analyze (with tokenizer and filter)
### Description
Analyzes text using a specified tokenizer and token filter.
### Method
POST
### Endpoint
/api/_analyze
### Request Body
- **tokenizer** (string) - Required - The name of the tokenizer to use (e.g., "standard").
- **char_filter** (array of strings) - Optional - A list of character filters to apply (e.g., ["html"]).
- **token_filter** (array of strings) - Optional - A list of token filters to apply (e.g., ["camel_case"]).
- **text** (string) - Required - The text to be analyzed.
### Request Example
```json
{
"tokenizer" : "standard",
"char_filter" : ["html"],
"token_filter" : ["camel_case"],
"text" : "50 first dates"
}
```
```
--------------------------------
### Windows Binary Installation and Execution
Source: https://zincsearch-docs.zinc.dev/installation
Set environment variables for the first admin user and password, create a data directory, and run the ZincSearch executable on Windows.
```bash
set ZINC_FIRST_ADMIN_USER=admin
set ZINC_FIRST_ADMIN_PASSWORD=Complexpass#123
mkdir data
zincsearch.exe
```
--------------------------------
### Linux Binary Installation and Execution
Source: https://zincsearch-docs.zinc.dev/installation
Create a data directory and run the ZincSearch binary with the first admin user and password environment variables set.
```bash
mkdir data
ZINC_FIRST_ADMIN_USER=admin ZINC_FIRST_ADMIN_PASSWORD=Complexpass#123 ./zincsearch
```
--------------------------------
### Analyze with Special Tokenizer
Source: https://zincsearch-docs.zinc.dev/api/index/analyze
This example demonstrates how to use a specific tokenizer along with the text for analysis.
```APIDOC
## POST /api/_analyze (with tokenizer)
### Description
Analyzes text using a specified tokenizer.
### Method
POST
### Endpoint
/api/_analyze
### Request Body
- **tokenizer** (string) - Required - The name of the tokenizer to use (e.g., "standard").
- **text** (string) - Required - The text to be analyzed.
### Request Example
```json
{
"tokenizer" : "standard",
"text" : "50 first dates"
}
```
```
--------------------------------
### Search Response Example
Source: https://zincsearch-docs.zinc.dev/api-es-compatible/search/search
This is an example of a successful search response. It includes metadata about the search execution, such as the time taken and shard status, along with the actual search results ('hits'). Each hit contains the document's index, type, ID, score, and source data.
```json
{
"took": 0,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 11
},
"max_score": 12.214994762453479,
"hits": [
{
"_index": "olympics",
"_type": "_doc",
"_id": "1P0sQ6wY926",
"_score": 12.214994762453479,
"@timestamp": "2022-05-26T11:51:31.761150823Z",
"_source": {
"Athlete": "HOPPENBERG, Ernst",
"City": "Paris",
"Country": "GER",
"Discipline": "Swimming",
"Event": "200M Backstroke",
"Gender": "Men",
"Medal": "Gold",
"Season": "summer",
"Sport": "Aquatics",
"Year": 1900
}
},
{
"_index": "olympics",
"_type": "_doc",
"_id": "1P0sQ6wY92j",
"_score": 12.214994762453479,
"@timestamp": "2022-05-26T11:51:31.761346257Z",
"_source": {
"Athlete": "FREY, Julius",
"City": "Paris",
"Country": "GER",
"Discipline": "Swimming",
"Event": "200M Team Swimming",
"Gender": "Men",
"Medal": "Gold",
"Season": "summer",
"Sport": "Aquatics",
"Year": 1900
}
},
{
"_index": "olympics",
"_type": "_doc",
"_id": "1P0sQ6wY92k",
"_score": 12.214994762453479,
"@timestamp": "2022-05-26T11:51:31.761361703Z",
"_source": {
"Athlete": "HAINLE, Max",
"City": "Paris",
"Country": "GER",
"Discipline": "Swimming",
"Event": "200M Team Swimming",
"Gender": "Men",
"Medal": "Gold",
"Season": "summer",
"Sport": "Aquatics",
"Year": 1900
}
},
{
"_index": "olympics",
"_type": "_doc",
"_id": "1P0sQ6wY92l",
"_score": 12.214994762453479,
"@timestamp": "2022-05-26T11:51:31.761376725Z",
"_source": {
"Athlete": "HOPPENBERG, Ernst",
"City": "Paris",
"Country": "GER",
"Discipline": "Swimming",
"Event": "200M Team Swimming",
"Gender": "Men",
"Medal": "Gold",
"Season": "summer",
"Sport": "Aquatics",
"Year": 1900
}
},
{
"_index": "olympics",
"_type": "_doc",
"_id": "1P0sQ6wY92m",
"_score": 12.214994762453479,
"@timestamp": "2022-05-26T11:51:31.761388544Z",
"_source": {
"Athlete": "SCHÖNE, Max",
"City": "Paris",
"Country": "GER",
"Discipline": "Swimming",
"Event": "200M Team Swimming",
"Gender": "Men",
"Medal": "Gold",
"Season": "summer",
"Sport": "Aquatics",
"Year": 1900
}
},
{
"_index": "olympics",
"_type": "_doc",
"_id": "1P0sQ6wY92n",
"_score": 12.214994762453479,
"@timestamp": "2022-05-26T11:51:31.761400515Z",
"_source": {
"Athlete": "VON PETERSDORFF, Herbert",
"City": "Paris",
"Country": "GER",
"Discipline": "Swimming",
"Event": "200M Team Swimming",
"Gender": "Men",
"Medal": "Gold",
"Season": "summer",
"Sport": "Aquatics",
"Year": 1900
}
}
]
}
}
```
--------------------------------
### Bulk v2 API Example Payload
Source: https://zincsearch-docs.zinc.dev/api/document/bulkv2
An example payload for the Bulk v2 API, demonstrating the insertion of Olympic Games data into the 'olympics' index.
```json
{
"index" : "olympics",
"records": [
{"Year": 1896, "City": "Athens", "Sport": "Aquatics", "Discipline": "Swimming", "Athlete": "HAJOS, Alfred", "Country": "HUN", "Gender": "Men", "Event": "100M Freestyle", "Medal": "Gold", "Season": "summer"},
{"Year": 1896, "City": "Athens", "Sport": "Aquatics", "Discipline": "Swimming", "Athlete": "HERSCHMANN, Otto", "Country": "AUT", "Gender": "Men", "Event": "100M Freestyle", "Medal": "Silver", "Season": "summer"},
{"Year": 1896, "City": "Athens", "Sport": "Aquatics", "Discipline": "Swimming", "Athlete": "CHASAPIS, Spiridon", "Country": "GRE", "Gender": "Men", "Event": "100M Freestyle For Sailors", "Medal": "Silver", "Season": "summer"}
]
}
```
--------------------------------
### Example Multi-line JSON Documents
Source: https://zincsearch-docs.zinc.dev/api/document/multi
This shows the format for multiple line JSON documents that can be sent in a single request.
```json
{ "title": "this is the first document", "attr": "foo" }
{ "title": "this is the second document", "attr": "bar" }
```
--------------------------------
### GET /api/:target/_settings
Source: https://zincsearch-docs.zinc.dev/api/index/get-settings
Retrieves the settings for a specified index.
```APIDOC
## GET /api/:target/_settings
### Description
Get an index settings.
### Method
GET
### Endpoint
/api/:target/_settings
### Request Example
GET http://localhost:4080/api/myindex/_settings
### Response
#### Success Response (200)
- **myindex** (object) - Contains the settings for the index.
- **settings** (object) - The index settings.
- **analysis** (object) - Analysis settings for the index.
- **analyzer** (object) - Analyzer configurations.
- **default** (object) - Default analyzer settings.
- **type** (string) - The type of the default analyzer.
#### Response Example
```json
{
"myindex": {
"settings": {
"analysis": {
"analyzer": {
"default": {
"type": "standard"
}
}
}
}
}
}
```
```
--------------------------------
### Get License Status
Source: https://zincsearch-docs.zinc.dev/api-es-compatible/_license
Retrieves the current license status. This is a dummy endpoint for ES compatibility.
```http
GET /es/_license
```
```json
{
"status": "active"
}
```
--------------------------------
### Python Search Example
Source: https://zincsearch-docs.zinc.dev/api/search/search
Demonstrates how to perform a search using Python's requests library. Includes basic authentication and constructing the search parameters. The commented-out section shows an alternative 'querystring' search type.
```python
import base64
import json
import requests
user = "admin"
password = "Complexpass#123"
bas64encoded_creds = base64.b64encode(bytes(user + ":" + password, "utf-8")).decode("utf-8")
params = {
"search_type": "match",
"query":
{
"term": "DEMTSCHENKO",
"start_time": "2021-06-02T14:28:31.894Z",
"end_time": "2021-12-02T15:28:31.894Z"
},
"from": 0,
"max_results": 20,
"_source": []
}
# params = {
# "search_type": "querystring",
# "query":
# {
# "term": "+City:Turin +Silver",
# "start_time": "2021-06-02T14:28:31.894Z",
# "end_time": "2021-12-02T15:28:31.894Z"
# },
# "_source": ["_all"]
# }
headers = {"Content-type": "application/json", "Authorization": "Basic " + bas64encoded_creds}
index = "games3"
zinc_host = "http://localhost:4080"
zinc_url = zinc_host + "/api/" + index + "/_search"
res = requests.post(zinc_url, headers=headers, data=json.dumps(params))
print(res.text)
```
--------------------------------
### Deploy ZincSearch using Helm
Source: https://zincsearch-docs.zinc.dev/quickstart
Create a namespace, update Helm values in values.yaml, and then install the ZincSearch chart. Make ZincSearch available via an ingress or port-forward.
```bash
kubectl create ns zincsearch
helm install zincsearch helm/zincsearch -n zincsearch
kubectl -n zincsearch port-forward svc/zincsearch 4080:4080
```
--------------------------------
### Search with Aggregations
Source: https://zincsearch-docs.zinc.dev/api-es-compatible/search/aggregation
This example demonstrates a search query that includes multiple aggregation types such as terms, range, date_range, and various metric aggregations. Use this to analyze and group your search results.
```json
{
"query": {
"bool": {
"should": {
"match": {
"_all": "Ice Hockey"
}
}
}
},
"sort": ["-@timestamp"],
"from": 0,
"size": 20,
"aggs": {
"Medal": {
"terms": {
"field": "Medal",
"size": 10
}
},
"Year": {
"range": {
"field": "Year",
"ranges": [
{ "from": 1900, "to": 1920},
{ "from": 1921, "to": 1950},
{ "from": 1951, "to": 2000},
{ "from": 2000, "to": 2021}
]
}
},
"@timestamp": {
"date_range": {
"field": "@timestamp",
"ranges": [
{ "from": "2020-01-21T09:22:50.604Z", "to": "2021-01-21T09:22:50.604Z"},
{ "from": "2021-01-22T09:22:50.604Z", "to": "2023-01-21T09:22:50.604Z"}
]
}
},
"max_Year": {
"max": { "field": "Year" }
},
"min_Year": {
"min": { "field": "Year" }
},
"avg_Year": {
"avg": { "field": "Year" }
},
"weighted_avg_Year": {
"weighted_avg": {
"field": "Year",
"weight_field": "Year"
}
},
"sum_Year": {
"sum": { "field": "Year" }
},
"count_Sport": {
"count": { "field": "Sport" }
}
}
}
```
--------------------------------
### Analyze with Language Analyzer
Source: https://zincsearch-docs.zinc.dev/api/index/analyze
This example demonstrates using a language-specific analyzer for text analysis.
```APIDOC
## POST /api/_analyze (language analyzer)
### Description
Analyzes text using a language-specific analyzer.
### Method
POST
### Endpoint
/api/_analyze
### Request Body
- **analyzer** (string) - Required - The language code or name of the analyzer (e.g., "english" or "en").
- **text** (string) - Required - The text to be analyzed.
### Request Example (using full name)
```json
{
"analyzer" : "english",
"text" : "Hello World"
}
```
### Request Example (using short code)
```json
{
"analyzer" : "en",
"text" : "Hello World"
}
```
```
--------------------------------
### Multi Search Request Example
Source: https://zincsearch-docs.zinc.dev/api-es-compatible/search/msearch
Demonstrates how to send multiple search requests with different indices and queries using the _msearch API. Each request consists of a header specifying the index and a body containing the search query.
```json
{"index": "olympics"}
{ "query": { "bool": { "must": [ { "match": { "City": "paris" }}, { "match": { "Medal": "gold" }} ], "filter": [ { "term": { "Country": "ger" }}, { "range": { "@timestamp": { "gte": "2015-01-01", "format": "2006-01-02" }}} ] } } }
{"index": "olympics"}
{"query" : {"match_all" : {}}}
```
--------------------------------
### X-Pack API Compatibility Check
Source: https://zincsearch-docs.zinc.dev/api-es-compatible/_xpack
Use this GET request to check for X-Pack API compatibility. It returns build, features, and license information.
```http
GET /es/_xpack
```
```json
{
"build": {
},
"features": {
},
"license": {
"status": "active"
}
}
```
--------------------------------
### Analyze with Chinese Analyzer
Source: https://zincsearch-docs.zinc.dev/api/index/analyze
This example shows how to use Chinese-specific analyzers for text analysis.
```APIDOC
## POST /api/_analyze (Chinese analyzer)
### Description
Analyzes Chinese text using a specified Chinese analyzer.
### Method
POST
### Endpoint
/api/_analyze
### Request Body
- **analyzer** (string) - Required - The name of the Chinese analyzer (e.g., "gse_search" or "gse_standard").
- **text** (string) - Required - The Chinese text to be analyzed.
### Request Example (gse_search)
```json
{
"analyzer" : "gse_search",
"text" : "你好世界"
}
```
### Request Example (gse_standard)
```json
{
"analyzer" : "gse_standard",
"text" : "你好世界"
}
```
```
--------------------------------
### Batch Document Creation Payload
Source: https://zincsearch-docs.zinc.dev/api/document/multi
This example demonstrates the payload structure for creating multiple documents in a batch. Each line represents a distinct JSON document.
```json
{"Year": 1896, "City": "Athens", "Sport": "Aquatics", "Discipline": "Swimming", "Athlete": "HAJOS, Alfred", "Country": "HUN", "Gender": "Men", "Event": "100M Freestyle", "Medal": "Gold", "Season": "summer"}
{"Year": 1896, "City": "Athens", "Sport": "Aquatics", "Discipline": "Swimming", "Athlete": "HERSCHMANN, Otto", "Country": "AUT", "Gender": "Men", "Event": "100M Freestyle", "Medal": "Silver", "Season": "summer"}
{"Year": 1896, "City": "Athens", "Sport": "Aquatics", "Discipline": "Swimming", "Athlete": "CHASAPIS, Spiridon", "Country": "GRE", "Gender": "Men", "Event": "100M Freestyle For Sailors", "Medal": "Silver", "Season": "summer"}
```
--------------------------------
### GET /es/_xpack
Source: https://zincsearch-docs.zinc.dev/api-es-compatible/_xpack
This endpoint provides compatibility with the Elasticsearch _xpack API. It returns information about the build, features, and license status.
```APIDOC
## GET /es/_xpack
### Description
Provides compatibility with the Elasticsearch _xpack API, returning build, features, and license status information.
### Method
GET
### Endpoint
/es/_xpack
### Response
#### Success Response (200)
- **build** (object) - Information about the build.
- **features** (object) - Information about available features.
- **license** (object) - Information about the license status.
- **status** (string) - The status of the license (e.g., "active").
#### Response Example
```json
{
"build": {},
"features": {},
"license": {
"status": "active"
}
}
```
```
--------------------------------
### Index Response Structure
Source: https://zincsearch-docs.zinc.dev/api/index/list
Example of the JSON response structure when listing all indexes. It includes details about the index list and pagination information.
```json
{
"list": [
{
"name": "fluent.warn-20220803",
"storage_type": "disk",
"shard_num": 3,
"settings": {},
"mappings": {
"properties": {
"@timestamp": {
"type": "date",
"index": true,
"store": false,
"sortable": true,
"aggregatable": true,
"highlightable": false
},
"_id": {
"type": "keyword",
"index": true,
"store": false,
"sortable": true,
"aggregatable": true,
"highlightable": false
},
"chunk": {
"type": "text",
"index": true,
"store": false,
"sortable": false,
"aggregatable": false,
"highlightable": false
},
"retry_times": {
"type": "numeric",
"index": true,
"store": false,
"sortable": true,
"aggregatable": true,
"highlightable": false
}
}
},
"stats": {
"doc_time_min": 0,
"doc_time_max": 0,
"doc_num": 7,
"storage_size": 61514,
"wal_size": 0
},
"version": ""
}
],
"page": {
"page_num": 1,
"page_size": 20,
"total": 1
}
}
```
--------------------------------
### Fluentd Configuration for Elasticsearch and Stdout
Source: https://zincsearch-docs.zinc.dev/ingestion/fluentd
This configuration sets up Fluentd to receive data via the forward input plugin and then copies it to both an Elasticsearch instance and the standard output. Ensure fluent-plugin-elasticsearch is installed.
```fluentd
@type forward
port 24224
bind 0.0.0.0
@type copy
@type elasticsearch
host 192.168.3.22
port 4080
path /es
user admin
password "Complexpass#123"
logstash_format true
logstash_prefix ${tag}
logstash_dateformat %Y%m%d
include_tag_key true
type_name access_log
tag_key @log_name
@type stdout
```
--------------------------------
### Inverted Index Example
Source: https://zincsearch-docs.zinc.dev/concepts
Illustrates how an inverted index maps terms to document IDs. This structure allows for efficient full-text searching.
```json
{"id":1, "message: "Prabhat Sharma is a cool guy to hang with"}
```
```json
{"id":2, "message: "Prabhat Sharma is in San Francisco"}
```
--------------------------------
### List All Indexes
Source: https://zincsearch-docs.zinc.dev/api/index/list
Retrieve a list of all existing indexes. Supports pagination, sorting by various fields, and fuzzy searching by name. Use this to get detailed information about each index.
```http
GET http://localhost:4080/api/index?page_num=1&page_size=20&sort_by=name&desc=false&name=f
```
--------------------------------
### Search with Boolean Query
Source: https://zincsearch-docs.zinc.dev/api-es-compatible/search/search
This example demonstrates how to perform a search using a boolean query. It includes 'must' and 'filter' clauses to narrow down the results. The 'must' clause requires both 'City' to be 'paris' and 'Medal' to be 'gold'. The 'filter' clause further restricts results to 'Country' being 'ger' and the '@timestamp' being on or after '2015-01-01'. The 'size' parameter limits the number of returned documents to 10.
```APIDOC
## POST /es/olympics/_search
### Description
Performs a search query against the 'olympics' index using a boolean query structure.
### Method
POST
### Endpoint
/es/olympics/_search
### Request Body
- **query** (object) - Required - The search query definition.
- **bool** (object) - Required - Defines the boolean logic for the query.
- **must** (array) - Optional - Clauses that must all match.
- **match** (object) - Required - Matches analyzed text fields.
- **City** (string) - Required - The city to match.
- **Medal** (string) - Required - The medal to match.
- **should** (array) - Optional - Clauses that should match (scoring boost).
- **must_not** (array) - Optional - Clauses that must not match.
- **filter** (array) - Optional - Clauses that must match but without scoring.
- **term** (object) - Required - Matches exact values in fields.
- **Country** (string) - Required - The country code to match.
- **range** (object) - Required - Matches values within a specified range.
- **@timestamp** (object) - Required - The timestamp field to filter on.
- **gte** (string) - Required - Greater than or equal to the specified date.
- **format** (string) - Optional - The date format.
- **size** (integer) - Optional - The maximum number of hits to return.
### Request Example
```json
{
"query": {
"bool": {
"must": [
{ "match": { "City": "paris" }},
{ "match": { "Medal": "gold" }}
],
"should": [],
"must_not": [],
"filter": [
{ "term": { "Country": "ger" }},
{ "range": { "@timestamp": { "gte": "2015-01-01", "format": "2006-01-02" }}}
]
}
},
"size": 10
}
```
### Response
#### Success Response (200)
- **took** (integer) - The time in milliseconds for the search to execute.
- **timed_out** (boolean) - Indicates if the search timed out.
- **_shards** (object) - Information about the shards processed.
- **total** (integer) - Total number of shards.
- **successful** (integer) - Number of successful shards.
- **skipped** (integer) - Number of skipped shards.
- **failed** (integer) - Number of failed shards.
- **hits** (object) - Contains the search results.
- **total** (object) - Information about the total number of hits.
- **value** (integer) - The total number of hits.
- **max_score** (float) - The maximum score of the hits.
- **hits** (array) - An array of hit objects.
- **_index** (string) - The index the hit belongs to.
- **_type** (string) - The type of the document.
- **_id** (string) - The ID of the document.
- **_score** (float) - The score of the hit.
- **@timestamp** (string) - The timestamp of the document.
- **_source** (object) - The original source of the document.
- **Athlete** (string) - The athlete's name.
- **City** (string) - The city where the event took place.
- **Country** (string) - The country code.
- **Discipline** (string) - The discipline of the sport.
- **Event** (string) - The specific event.
- **Gender** (string) - The gender of the athlete.
- **Medal** (string) - The medal won.
- **Season** (string) - The season of the Olympics.
- **Sport** (string) - The sport.
- **Year** (integer) - The year of the event.
#### Response Example
```json
{
"took": 0,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 11
},
"max_score": 12.214994762453479,
"hits": [
{
"_index": "olympics",
"_type": "_doc",
"_id": "1P0sQ6wY926",
"_score": 12.214994762453479,
"@timestamp": "2022-05-26T11:51:31.761150823Z",
"_source": {
"Athlete": "HOPPENBERG, Ernst",
"City": "Paris",
"Country": "GER",
"Discipline": "Swimming",
"Event": "200M Backstroke",
"Gender": "Men",
"Medal": "Gold",
"Season": "summer",
"Sport": "Aquatics",
"Year": 1900
}
}
]
}
}
```
```
--------------------------------
### Get Current Version
Source: https://zincsearch-docs.zinc.dev/api/version
Retrieves the current version of ZincSearch. This is a simple GET request to the /version endpoint.
```APIDOC
## GET /version
### Description
Retrieves the current version of ZincSearch.
### Method
GET
### Endpoint
/version
### Request Example
```
GET http://localhost:4080/version
```
### Response
#### Success Response (200)
- **version** (string) - The current version of ZincSearch.
```
--------------------------------
### Deploy ZincSearch using Kubernetes Manifest
Source: https://zincsearch-docs.zinc.dev/quickstart
Create a namespace for ZincSearch and then apply the Kubernetes deployment manifest. Expose the service by port-forwarding.
```bash
kubectl create ns zincsearch
kubectl apply -f https://raw.githubusercontent.com/zincsearch/zincsearch/main/k8s/kube-deployment.yaml
kubectl -n zincsearch port-forward svc/z 4080:4080
```
--------------------------------
### Kubernetes Deployment Manifest
Source: https://zincsearch-docs.zinc.dev/installation
Create a namespace and apply the Kubernetes deployment manifest to set up ZincSearch.
```bash
kubectl create ns zincsearch
kubectl apply -f https://raw.githubusercontent.com/zincsearch/zincsearch/main/k8s/kube-deployment.yaml
```
--------------------------------
### Create Document
Source: https://zincsearch-docs.zinc.dev/api/document/create
Creates a document and indexes it for searches.
```APIDOC
## POST /api/:target/_doc
### Description
Create a document and index it for searches.
### Method
POST
### Endpoint
/api/:target/_doc
### Request Body
```json
{
"name": "Prabhat Sharma"
}
```
### Request Example
```
POST http://localhost:4080/api/myindex/_doc
{
"name": "Prabhat Sharma"
}
```
```