Skip to content

Commit

Permalink
Update elastic indexer documentation (#1016)
Browse files Browse the repository at this point in the history
* update documentation es indices

* fixes

* fix

* fixes

* fixes after second review

* links
  • Loading branch information
miiu96 authored Nov 27, 2024
1 parent 73e0ef6 commit 5b3b05b
Show file tree
Hide file tree
Showing 8 changed files with 242 additions and 24 deletions.
43 changes: 22 additions & 21 deletions docs/sdk-and-tools/elastic-search.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,27 +125,28 @@ Each entry in an Elasticsearch index will have a format similar to this:
}
```

| Name | Description |
| -------------------------------------------------------------------------- | --------------------------------------------------------------------------- |
| [transactions](/sdk-and-tools/indices/es-index-transactions) | Contains all transactions. |
| [blocks](/sdk-and-tools/indices/es-index-blocks) | Contains all executed blocks. |
| [validators](/sdk-and-tools/indices/es-index-validators) | Contains the public keys of the validators grouped by epoch and shard. |
| [rating](/sdk-and-tools/indices/es-index-rating) | Contains the validators' rating for every epoch. |
| [miniblocks](/sdk-and-tools/indices/es-index-miniblocks) | Contains all executed minblocks. |
| [rounds](/sdk-and-tools/indices/es-index-rounds) | Contains details of each round that has passed. |
| [accounts](/sdk-and-tools/indices/es-index-accounts) | Contains the addresses' balances and the timestamp when they were modified. |
| [accountshistory](/sdk-and-tools/indices/es-index-accountshistory) | Contains historical information about the address balances. |
| [receipts](/sdk-and-tools/indices/es-index-receipts) | Contains all generated receipts. |
| [scresults](/sdk-and-tools/indices/es-index-scresults) | Contains all generated smart contract results. |
| [accountsesdt](/sdk-and-tools/indices/es-index-accountsesdt) | Contains the addresses' ESDT balances. |
| [accountsesdthistory](/sdk-and-tools/indices/es-index-accountsesdthistory) | Contains historical information about the address ESDT balances. |
| [epochinfo](/sdk-and-tools/indices/es-index-epochinfo) | Contains the accumulated fees and the developer fees grouped by epochs. |
| [scdeploys](/sdk-and-tools/indices/es-index-scdeploys) | Contains details about all the deployed smart contracts. |
| [tokens](/sdk-and-tools/indices/es-index-tokens) | Contains all created ESDT tokens. |
| [tags](/sdk-and-tools/indices/es-index-tags) | Contains the NFTs' tags. |
| [logs](/sdk-and-tools/indices/es-index-logs) | Contains all the logs generated by transactions and smart contract results. |
| [delegators](/sdk-and-tools/indices/es-index-delegators) | Contains details about all the delegators. |
| [operations](/sdk-and-tools/indices/es-index-operations) | Contains all transactions and smart contract results. |
| Name | Description |
|----------------------------------------------------------------------------|-------------------------------------------------------------------------------|
| [transactions](/sdk-and-tools/indices/es-index-transactions) | Contains all transactions. |
| [blocks](/sdk-and-tools/indices/es-index-blocks) | Contains all executed blocks. |
| [validators](/sdk-and-tools/indices/es-index-validators) | Contains the public keys of the validators grouped by epoch and shard. |
| [rating](/sdk-and-tools/indices/es-index-rating) | Contains the validators' rating for every epoch. |
| [miniblocks](/sdk-and-tools/indices/es-index-miniblocks) | Contains all executed minblocks. |
| [rounds](/sdk-and-tools/indices/es-index-rounds) | Contains details of each round that has passed. |
| [accounts](/sdk-and-tools/indices/es-index-accounts) | Contains the addresses' balances and the timestamp when they were modified. |
| [accountshistory](/sdk-and-tools/indices/es-index-accountshistory) | Contains historical information about the address balances. |
| [receipts](/sdk-and-tools/indices/es-index-receipts) | Contains all generated receipts. |
| [scresults](/sdk-and-tools/indices/es-index-scresults) | Contains all generated smart contract results. |
| [accountsesdt](/sdk-and-tools/indices/es-index-accountsesdt) | Contains the addresses' ESDT balances. |
| [accountsesdthistory](/sdk-and-tools/indices/es-index-accountsesdthistory) | Contains historical information about the address ESDT balances. |
| [epochinfo](/sdk-and-tools/indices/es-index-epochinfo) | Contains the accumulated fees and the developer fees grouped by epochs. |
| [scdeploys](/sdk-and-tools/indices/es-index-scdeploys) | Contains details about all the deployed smart contracts. |
| [tokens](/sdk-and-tools/indices/es-index-tokens) | Contains all created ESDT tokens. |
| [tags](/sdk-and-tools/indices/es-index-tags) | Contains the NFTs' tags. |
| [logs](/sdk-and-tools/indices/es-index-logs) | Contains all the logs generated by transactions and smart contract results. |
| [events](/sdk-and-tools/indices/es-index-events) | Contains all the events generated by transactions and smart contract results. |
| [delegators](/sdk-and-tools/indices/es-index-delegators) | Contains details about all the delegators. |
| [operations](/sdk-and-tools/indices/es-index-operations) | Contains all transactions and smart contract results. |

[comment]: # (mx-context-auto)

Expand Down
2 changes: 1 addition & 1 deletion docs/sdk-and-tools/indices/blocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ The `_id` field of this index is represented by the block hash, in a hexadecimal
| shardId | The shardId field represents the shard this block belongs to. |
| txCount | The txCount field represents the number of transactions that were executed in the block. |
| notarizedTxsCount | The notarizedTxsCount field represents the number of transactions that were notarized in the block. |
| accumulatedFees | The accumulatedFees field represents the accumulated fees that were paid in the block. |
| accumulatedFees | The accumulatedFees field represents the accumulated fees that were paid in the block. |
| developerFees | The developerFees field represents the developer fees that were accumulated in the block. |
| epochStartBlock | The epochStartBlock field is true if the current block is an epoch-start block. |
| epochStartInfo | The epochStartInfo field is a structure that contains economic data, such as total supply. |
Expand Down
79 changes: 79 additions & 0 deletions docs/sdk-and-tools/indices/events.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
---
id: es-index-events
title: events
---

[comment]: # (mx-abstract)

This page describes the structure of the `events` index (Elasticsearch), and also depicts a few examples of how to query it.

[comment]: # (mx-context-auto)

## _id

The `_id` field for this index is composed of hex-encoded hash of the transaction or the smart contract result that generated the log plus shard ID and order of event

example: `{hash}-{shardID}-{order}` (example: `abcd-2-1`).

[comment]: # (mx-context-auto)

## Fields

| Field | Description |
|----------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| logAddress | The address field holds the address in bech32 encoding. It can be the address of the smart contract that generated the log or the address of the receiver of the transaction. |
| address | The address field holds the address in bech32 encoding. It can be the address of the smart contract that generated the event or the address of the receiver of the transaction. |
| txHash | The txHash field field for this index is composed of hex-encoded hash of the transaction or the smart contract result that generated the log. |
| originalTxHash | The originalTxHash field holds the hex-encoded hash of the initial transaction. When this field is not empty the log is generated by a smart contract result and this field represents the hash of the initial transaction. |
| timestamp | The timestamp field represents the timestamp of the block in which the log was generated. |
| identifier | This field represents the identifier of the event. |
| topics | The topics field holds a list with extra information, hex-encoded. They don't have a specific order because the smart contract is free to log anything that could be helpful. |
| data | The data field can contain information added by the smart contract that generated the event, hex-encoded. |
| order | The order field represents the index of the event indicating the execution order. |
| txOrder | The txOrder field represents the execution order of transaction/smart contract who generated this event. |
| timestamp | The timestamp field represents the timestamp of the block in which the event was generated. |
| shardID | The shardID field represents the shard this events belongs to. |


## Query examples

### Fetch all the events generated by a transaction

```
curl --request GET \
--url ${ES_URL}/events/_search \
--header 'Content-Type: application/json' \
--data '{
"query": {
"match": {
"txHash":"d6.."
}
}
}'
```

### Fetch all the events generated by a transaction and the smart contract results triggered by it

```
curl --request GET \
--url ${ES_URL}/events/_search \
--header 'Content-Type: application/json' \
--data '{
"query": {
"bool": {
"should": [
{
"match": {
"_id":"d6.."
}
},
{
"match": {
"originalTxHash": "d6.."
}
}
]
}
}
}'
```
9 changes: 9 additions & 0 deletions docs/sdk-and-tools/indices/logs.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ This page describes the structure of the `logs` index (Elasticsearch), and also

## _id

:::warning Important

**The `logs` index will be deprecated and removed in the near future.**
We recommend using the [events](/sdk-and-tools/indices/es-index-events) index, which contains all the events included in a log.

Please make the necessary updates to ensure a smooth transition.
If you need further assistance, feel free to reach out.
:::

The `_id` field for this index is composed of hex-encoded hash of the transaction of the smart contract result that generated the log.

[comment]: # (mx-context-auto)
Expand Down
Loading

0 comments on commit 5b3b05b

Please sign in to comment.