Tag: 索引

neo4jrestAPI唯一性不工作?

我试图在neo4j中创build一个独特的节点,但不能使它工作。 节点代码: var node = db.createNode({sampleDataKey: "sampleDataValue"}); node.save(function (err, user) { node.index('user', 'indexValue', 'indexValue', function (err) { if (err) console.log(err); console.log(user.id); }); }); 我正在使用这个节点模块: https : //github.com/thingdom/node-neo4j 我修改了neo4j库中的Node.js。 至: else { var urlToPost = ((("" + services.node_index) + "/") + index + '?uniqueness=create_or_fail'); console.log(urlToPost); console.log(key + ':' + value); /* 123 */ return __this._request.post({ /* […]

使用JavaScript将最新的数组索引存储在单独的数组中

我有一个对象的数组。 数组的键是使用.push()自动生成的。 有些对象可能会从数组中delete array[index]; 。 数组可能包含0到10K +条目中的任何内容。 这是声明和一些逻辑: var allClients = []; someFunction(client) { allClients.push(client); var callbackFunction = function() { var index = allClients.indexOf(client); try { delete allClients[index]; } catch (err) { console.error(err); } } } function getClientsMeetingCriteria(some_unique_id) { var filteredClients = allClients.filter(function(client) { return client.id_list.indexOf(some_unique_id) > -1; }); return filteredClients; } 现在上面的代码(它是IRL的非常简化的版本)适用于100-300个客户端,但是对于500+的目的而言,它变得太慢了。 问题是getClientsMeetingCriteria()可能asynchronous每秒调用10次。 我需要设置与some_unique_idcaching作为关键。 […]

MongoDB查询索引$ gt和$ ne

询问 我有这样的查询: db.sample.find({ bool1: false, theNull: null, existing: {$ne: null}, $or: [ { bool2: false, string: {$in: [<array of strings>]}}, { bool2: true, string: {$in: [<array of different strings>]}} ], dateField: {$lt: ISODate(<Given date>)} }).sort({dateField: -1}); 题 我正在寻找build立一个最佳的索引查询。 我打了很多,我想做得更好。 查询的部分 我的文档在大多数情况下(99.9%以上)将bool1设置为false , theNull为null, existing的95%的情况下不为null – 所以我需要这些字段(某处)将其过滤掉。 dateField是我sorting。 现在,我的有趣的数据集是string和bool2 – 这里是我有文档的变化,这基本上是查询过滤。 string总是来自相对包含的一组string(实际上是用户名),而bool2在文档数量非常less的情况下为真。 dateField大部分是连续的,实际的插入时间,但是在这里和那里存在差距,因为在一系列10-100个文档中,我必须将date移回几个月。 我到目前为止做了什么 迄今为止最好的结果是设定这些指标: { […]

如何在我的网站与mongoose和MongoDB实现一个search引擎

我想实现一个searchfunction,以部分或完整的方式search用户,例如Bob = Bob Herald,Bob Granger。 我是新的节点js请帮助。

应该在应用程序设置中调用ensureIndex?

每当应用程序发生变化时调用ensureIndex是否合适,例如在app.configure ? 除了稍微慢一些的启动时间之外,它是否有任何缺点,而不是仅仅为新的mongo实例设置呢?

Node.js或C(不包括全文search)的大小写不敏感,确切的子string匹配/索引

哪些库在Node.js中提供大小写不敏感的确切子string匹配,以及大量的string? 我正在寻找基于索引的解决scheme。 举一个例子,考虑一个语料库包含数百万个string: "Abc Gef gHi" "Def Ghi xYz" … 我需要一个库,以便search"C ge"返回上面的第一个string,但search"C ge" (注意多个空格)不会。 换句话说,我并不是在寻找模糊的,智能的,全文search的词干和停词; 而是一个最简单的(和快速的)准确的子串匹配器,其索引大规模工作。 JavaScript中的解决scheme是受欢迎的,C中的解决scheme也是如此 (因为它们可以变成本地的Node.js模块)。 另外, 其他编程语言(如Java)的解决scheme也是可能的 ; 他们可以通过命令行使用。 优选地,解决scheme是磁盘空间限制的而不是内存限制的(例如,而不是Redis),并且它们应该向磁盘写入索引,以便后续的启动时间很短。 我发现的大部分解决scheme(如这里的问题 )的问题是,它们太聪明了。 也就是说,他们应用不同的词干或标准化,所以比赛是不准确的。 在此先感谢您的帮助!

我如何解释()在MongoDB中的upsert来查看是否使用索引?

当代码改变时,快速告诉我索引是否适合find()语句是( nodejs ) collection.find(query).explain(function(err, explaination) { console.log('MongoDebug: ' + explaination.cursor); }); 如果游标是BtreeCursortypes,则使用索引。 如何在使用insert()和upsert: true时检查这个问题upsert: true ?

我可以在Mongoose的子文档中使用唯一索引吗?

我想要防止RecordList的重复插入,其中两个RecordsList是相同的,如果它们具有相同的Record集合,即相同的子文档数组。 这是架构: var RecordList = new Schema({ event: {type: ObjectId, ref: Event}, creator: {type: ObjectId, ref: User}, records: { type: [Record], unique: true } }, {strict: true, safe: true}) 但是,似乎unique: true records中的unique: true不起作用; 当我保存与数据库中现有的一个RecordSchema相同的RecordList时,重复被成功保存,但我希望它返回一个错误。 我是新来的mongoose,看了其他的SO问题,很长一段时间,mongoose的文档没有发现任何东西,据我所知。 对不起,如果这有一个明显的答案!

mongoose:在任何组合的一对字段上的唯一索引

唯一性在多个字段可能通常意味着您不能具有某些字段的组合相同的文档,如name1和name2 。 所以它将不允许存在两个文件{name1: 'Joe', name2: 'Bob'} 。 如果name1和name2切换,例如{name1: 'Bob', name2: 'Joe'}和{name1: 'Joe', name2: 'Bob'}这仍然允许文档同时存在。 有没有办法让一个独特的索引不允许这两个? (如果{name1: 'Bob', name2: 'Joe'}存在,既不可以{name1: 'Bob', name2: 'Joe'}也不可以{name1: 'Joe', name2: 'Bob'} )

Mongoose创build不在该scheme中的索引

mongoose有一个奇怪的行为。 在计划中,我有几个索引,但有时索引所有领域和其他时间索引只是_id 。 它从来没有像指标那样制定指数。 其他的scheme运作良好,但这一个特别是给我的问题。 也许是因为它有80个字段? 我的env是mongodb v2.4.12,节点v0.10.40,mongoose npm软件包v4.0.0 这是模式(为了清晰起见,我拿出了一些字段): 'use strict'; var log = require('../../../../lib/logging')(module.id), config = require('../../../../production.config'), me = module.exports = { name: 'natstransactions', model: { originType: { // postback or import type: String, index: true, unique: false, required: true }, type: { type: String, index: true, unique: false, required: true }, memberid: […]