You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is it possible to flatten or resolve references to other collections before indexing to Elasticsearch?
Example I have this schema:
var PartSchema = new mongoose.Schema({
title: {
type: String,
required: true
},
province : {
type : mongoose.Schema.ObjectId,
ref : 'Province',
required: true
},
});
Using mongoriver, the province property is being indexed as an ObjectId so in the search results of my application, the province is an object id so it's not useful to the users so I wanted to flatten/resolve the province property so I can access the properties of province like: part.province.name, part.province.createdAt etc...
My initial solution was to use script filters and mappings. Here's what I did:
ctx.document.province = {};
ctx.document.province.name = 'Static name to be inserted by script';
It works, but currently the name on the script is just static. Obviously I need to fetch it dynamically from mongodb database but I think it is not possible to use elasticsearch lang-javascript to query from mongodb?
Any ideas on how to solve my problem? Or maybe there are other ways to flatten/resolve object references before indexing to ES using mongoriver? Any suggestions will be greatly appreciated.
Thanks in advance :)
EDIT:
I'm thinking of using lang-javascript and communicate with MongoDB via a REST api using ajax but not sure if this is an efficient solution.
EDIT:
Tried using ajax, unfortunately it doesn't work since I think it's not possible to use ajax outside the browser.
Is it possible to flatten or resolve references to other collections before indexing to Elasticsearch?
Example I have this schema:
Using mongoriver, the province property is being indexed as an ObjectId so in the search results of my application, the province is an object id so it's not useful to the users so I wanted to flatten/resolve the province property so I can access the properties of province like: part.province.name, part.province.createdAt etc...
My initial solution was to use script filters and mappings. Here's what I did:
It works, but currently the name on the script is just static. Obviously I need to fetch it dynamically from mongodb database but I think it is not possible to use elasticsearch lang-javascript to query from mongodb?
Any ideas on how to solve my problem? Or maybe there are other ways to flatten/resolve object references before indexing to ES using mongoriver? Any suggestions will be greatly appreciated.
Thanks in advance :)
EDIT:
I'm thinking of using lang-javascript and communicate with MongoDB via a REST api using ajax but not sure if this is an efficient solution.
EDIT:
Tried using ajax, unfortunately it doesn't work since I think it's not possible to use ajax outside the browser.
Related problem: https://groups.google.com/forum/#!topic/elasticsearch/e3CelbOkgWk
The text was updated successfully, but these errors were encountered: