Hi All,
Please can you help me to how I can design my business case to elastic indexes.
My business case : we have users that can make many transactions and for each transaction can have many products .
In Relational Data base we have Table for users and table for users and transaction and table for transactions and products .
We used join to select between the tables . How I can design this in elastic ?
I suggest to create one index and contains nested objects for transaction and nested object for products .
Please can you help me to design my business case.
There are a couple of factor you need to consider, but first of all: don't think in "SQL terms". It's handy to visualize the relationships, but with Elasticsearch you are asked to think differently. Instead of your data split/spread out into different topical tables, you are supposed to think of a structured 'document'.
- how you structure your documents (define your field mappings) should depend on how you need to query those documents
- to take a document-centric approach, you need to denormalize your data
So instead of a separate entity relationship like User
-> Transaction
-> Product
, you might just have a transaction
document, that contains a nested products
array of objects along with a user
object.
- you can query to find transactions containing a given product(s)
- you can query to find transactions for a specific user
Something like:
{
"user": {
"id": 101,
"name": "Frank Sinatra"
},
"value": 159.78,
"currency": "USD",
"products: [{
"price": 14.95
"currency": "USD"
"count": 5,
"name": "6' Pool Noodle"
}, {
"price": 34.92
"currency": "USD"
"count": 2,
"name": "Rotten Zucchini"
}]
}
But, as I said earlier - it largely depends on how you want to query the data.
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.