我想通过嵌套数组中字符串的存在来检索文档.例如,数据(表示句子的依存关系分析)看起来像:
I would like to retrieve documents by the presence of an string in a nested array. For example, the data (representing a dependency parse of a sentence) looks like:
{'tuples': [['xcomp', 'multiply', 'using'], ['det', 'method', 'the'], ['nn', 'method', 'foil'], ['dobj', 'using', 'method']]}我找到的最接近的解决方案假定['nn', ...]是tuples列表列表的第二个位置:
The closest solution I've found assumes that ['nn', ...] is the second position of the tuples list-of-lists:
db.c.find({'tuples.2.0' : 'nn'})是否有一种方法可以放松固定位置?元组(不是它们的内容)可以是任意顺序.
Is there a way to relax the fixed position? The tuples (not their contents) can be in any order.
第二,能够检索具有['nn', 'method', X]的文档确实很棒,这意味着在其依赖项解析中有一个名词方法".
Secondly, it would be really great to be able to retrieve documents that have ['nn', 'method', X], meaning a noun "method" in their dependency parse.
谢谢!
推荐答案知道了!
db.c.find({'tuples' : {$elemMatch : {$all : ['nn']}}}) db.c.find({'tuples' : {$elemMatch : {$all : ['nn','method']}}})更多推荐
查询MongoDb中的嵌套数组
发布评论