Answer the question
In order to leave comments, you need to log in
How to bind data in elasticsearch?
I am using elastocsearch.js for full text search and MongoDB as database.
Tell me how to make an analogue of populate for the interests array (i.e. get data from the interests table that correspond to the id in the array).
[
{
"_index": "index",
"_type": "user",
"_id": "59ba5979ddb2072010a557c8",
"_score": 1.2068838,
"_source": {
"email": "[email protected]",
"interests": [
"599d5cd5e9d0f717e01512a7"
],
...
}
]
Answer the question
In order to leave comments, you need to log in
Initially, ElasticSearch itself does not know how to do this, and it was not planned to do so. It is important to understand that elasticsearch is not a database and does not have the same sorting features as relational databases. It is assumed that you add all the necessary data for possible query options to elasticsearch itself. Those. if you assumed that you would need to retrieve data by the corresponding id, then this data should have been added IMMEDIATELY to the schema! That is why elasticsearch comes as an addition to the database, and not as its substitute, although sometimes it can be suitable for storage, but not for an indefinite range of tasks, like relational databases.
Therefore, if you still want to use relationships, then only select data from mongo on your own based on id-shniks received from elasticsearch.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question