- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
Problem : In my example if i user schema.save then it will indexed in elastic search
but problem starts when i use findOneAndUpdate so it will not index in elastic even if i insert (i.e save)
MovieSchema.findOneAndUpdate(query, reqObject, {
upsert: true
}, function(err, results) {
if (err) {
if (!update) {
var filePath = path.join(__dirname, "../../movie/images/uploads/") + reqObject.imageUrl;
fs.unlinkSync(filePath);
}
console.log(err)
callback({
RESULT_CODE: '-1',
MESSAGE: 'System error. Please try again'
});
} else {
callback({
RESULT_CODE: '1',
MESSAGE: 'Movie inserted'
});
}
});
最佳答案
我喜欢使用findOneAndUpdate的答案
示例:
NOTE : pass new : true option upsert: true and it will work
New 选项将返回更新或创建的对象,因此内部 mongoosastic 工作就像插入的对象或更新的对象返回,然后它只会插入到 Elasticsearch 索引中
MovieSchema.findOneAndUpdate(query, reqObject, {
upsert: true,'new': true
}, function(err, results) {
if (err) {
callback({
RESULT_CODE: '-1',
MESSAGE: 'System error. Please try again'
});
} else {
callback({
RESULT_CODE: '1',
MESSAGE: 'Movie inserted'
});
}
});
关于node.js - mongoosastic findOneAndUpdate 不在elasticsearch 中建立索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33992359/
对于我的单元测试,在对我的 Mongoose 模式进行批量索引之前,我将使用 mongoosastic 截断我的模型。 架构: model: { name: {type: String, re
对于 Mongoose ,我的模式看起来像这样: var articleSchema = new Schema({ Name: {type: String, es_indexed: true}
所以该项目由下一个堆栈组成,NodeJS、Express、Mongodb、ElasticSearch。为了对 Elasticsearch 建立索引,我们使用插件 mongoosastic。 我有以下模
我已经安装了 Elasticsearch 和 Kibana。我有一个使用 NOdejs 和 MongoDB 的应用程序。这是我的架构配置: var userSchema = new mongoose.
我想使用 elasticsearch 为我的应用程序提供全文搜索,在谷歌搜索后我决定使用 mongoosastic,但该插件与 express 。那么是否有一个等效的插件可以将它与 loopback
我的目标是填充 mongoosastic 搜索中的某些字段,但如果我执行以下代码,它总是会返回 这是代码 var mongoose = require('mongoose'); var Categor
我有一个用 Angular js、Node.js、MongoDB 开发的聊天应用程序,具有 Elasticsearch 集成。我提供了聊天搜索功能,用户可以输入任意组合。选项包括聊天消息、用户和日期。
我正在使用Mongoosastic为了将我的模型索引到 Elasticsearch,它工作得很好,唯一的问题是我在分页的 From 和 Size 上遇到了问题。 根据 Mongoosastic api
我在mongoosastic的mongodb上使用elastic。 我的问题是当我对集合进行索引时。 Mongoosastic 只索引集合的一部分(例如,我的集合有 50,000 个文档,但 mong
目前我正在使用 mongoose Model.remove 方法来删除文档。但是在删除文档 mongoosastic 索引后仍然包含已删除的文档索引。 User.remove({_id:userI
我已经成功配置了 mongoosastic,我尝试搜索并且工作正常,但是当涉及到前端时,我不太确定如何实现这一点,我尝试了很多方法但无法实现想出一个好的解决方案。 这是代码。 // For the S
我正在尝试使用 mongoosastic 和 Elastic Search 创建一个自动完成功能,到目前为止,我已经能够使用 sense 创建它,但我无法将它移植到 mongoosastic。 我关注
Problem : In my example if i user schema.save then it will indexed in elastic search but problem sta
我在 MEAN 堆栈程序中设置了 mongoosastic。一切正常,除了当我从 mongodb 中删除文档时,它不会在 elasticsearch 索引中删除。因此,每次我进行包含删除项的搜索时,都
我正在尝试使用mongoosastic进行自动完成 我有以下代码: var ItemSchema = new Schema({ label: { type: String,
我正在尝试在我的 mongo db 数据库上创建搜索。我认为一个不错的选择是使用elasticsearch。所以我在 aws elastic search 上启动了一个集群。因为我有这个 Elasti
我正在尝试创建一个简单的搜索表单来在一个模型(产品)中进行搜索。 这是我使用 Mongoosastic 的产品模型: var ProductSchema = new Schema({ cate
这是错误 { Error: [mapper_parsing_exception] No handler for type [string] declared on field [type] a
我尝试引用两个模型。风格和品牌。 Brand 填充了所需的对象,但 Style 始终为空。 我试过清除缓存/删除索引。使用和不使用 include_in_parent 并键入:'nested'。 我觉
我在我的 Node.js 服务器中设置 mongoosastic 时遇到了麻烦。我按照视频讲座进行操作,但不起作用。 但是,有人说如果我降级elasticsearch版本就可以了。但我认为elasti
我是一名优秀的程序员,十分优秀!