@ocap/indexdb-elasticsearch
Version:
OCAP indexdb adapter that uses elasticsearch as backend
101 lines (97 loc) • 2.88 kB
JavaScript
module.exports = () => ({
mappings: {
dynamic: false,
properties: {
code: { type: 'keyword' },
hash: { type: 'keyword' },
time: { type: 'date' },
index: { type: 'integer' },
tags: { type: 'keyword' },
type: { type: 'keyword' },
valid: { type: 'boolean' },
tx: {
properties: {
chainId: { type: 'keyword' },
delegator: { type: 'keyword' },
from: { type: 'keyword' },
serviceFee: { type: 'keyword' },
gasFee: { type: 'keyword' },
gasPaid: { type: 'keyword' },
nonce: { type: 'text', index: false },
pk: { type: 'text', index: false },
signature: { type: 'text', index: false },
signatures: {
type: 'nested',
properties: {
delegator: { type: 'keyword' },
signer: { type: 'keyword' },
pk: { type: 'text', index: false },
signature: { type: 'text', index: false },
data: { type: 'object' },
},
},
itx: {
type: 'nested',
properties: {
__typename: { type: 'keyword' },
},
},
itxJson: {
type: 'nested',
properties: {
_type: { type: 'keyword' },
type_url: { type: 'keyword' },
encoded_value: { type: 'text', index: false },
data: {
type: 'nested',
properties: {
type: { type: 'keyword' },
value: { type: 'text', index: false },
},
},
// Other per protocol fields can be added below
},
},
},
},
tokenSymbols: {
type: 'nested',
properties: {
address: { type: 'keyword' },
symbol: { type: 'keyword' },
decimal: { type: 'keyword' },
unit: { type: 'keyword' },
},
},
receipts: {
type: 'nested',
properties: {
address: { type: 'keyword' },
changes: {
type: 'nested',
properties: {
target: { type: 'keyword' },
action: { type: 'keyword' },
value: { type: 'keyword' },
},
},
},
},
assets: { type: 'keyword' },
factories: { type: 'keyword' },
tokens: { type: 'keyword' },
accounts: { type: 'keyword' },
sender: { type: 'keyword' },
receiver: { type: 'keyword' },
stakes: { type: 'keyword' },
rollups: { type: 'keyword' },
delegations: { type: 'keyword' },
},
},
settings: {
index: {
number_of_shards: +(process.env.ES_SHARD_COUNT || 1),
number_of_replicas: +(process.env.ES_REPLICA_COUNT || 0),
},
},
});