左外部与蒙哥多(Mongodb)
我已经用sqlitemongo
将我的SQLITE3数据库迁移到MongoDB,但是我现在很难将SQL查询转换为与MongoDB一起使用。我有两个集合,它们采用以下格式:
word2vec
[
{
"_id":{"$numberInt":"1"},
"word":"olla",
"vec":<VEC_DATA>
},
{
"_id":{"$numberInt":"2"},
"word":"että",
"vec":<VEC_DATA>
}
]
附近
[
{
"_id":{"$numberInt":"1"},
"word":"arvostus",
"neighbor":"nostattaa",
"similarity":{"$numberDouble":"0.3088807761669159"},
"percentile":{"$numberInt":"29"}
},
{
"_id":{"$numberInt":"2"},
"word":"arvostus",
"neighbor":"että",
"similarity":{"$numberDouble":"0.3020103059369159"},
"percentile":{"$numberInt":"30"}
}
]
我在外观上挣扎的第一个查询:
SELECT vec, percentile
FROM word2vec LEFT OUTER JOIN nearby
ON nearby.word = <var1> and nearby.neighbor = <var2>
WHERE word2vec.word = <var2>
,其中&lt; var1 /code>和
&lt; var2&gt;
是在不同查询上具有不同值的字符串。它们以参数为参数,以运行查询的函数。我需要数据库返回vec
值,无论是否找到匹配的percodile
。每当发现时都使用。我找到了一些有关在Mongo可以完成左联合的信息,但是没有一个示例甚至没有接近我所寻找的。
有人知道如何在Mongo中进行此类查询吗?有可能吗?
I have migrated my sqlite3 database to MongoDB with sqlitemongo
, but I'm now having a hard time converting SQL queries to work with MongoDB. I have two collections, which are in the following format:
word2vec
[
{
"_id":{"$numberInt":"1"},
"word":"olla",
"vec":<VEC_DATA>
},
{
"_id":{"$numberInt":"2"},
"word":"että",
"vec":<VEC_DATA>
}
]
nearby
[
{
"_id":{"$numberInt":"1"},
"word":"arvostus",
"neighbor":"nostattaa",
"similarity":{"$numberDouble":"0.3088807761669159"},
"percentile":{"$numberInt":"29"}
},
{
"_id":{"$numberInt":"2"},
"word":"arvostus",
"neighbor":"että",
"similarity":{"$numberDouble":"0.3020103059369159"},
"percentile":{"$numberInt":"30"}
}
]
The first query I'm struggling with looks like this:
SELECT vec, percentile
FROM word2vec LEFT OUTER JOIN nearby
ON nearby.word = <var1> and nearby.neighbor = <var2>
WHERE word2vec.word = <var2>
, where <var1>
and <var2>
are strings that have different values on different queries. They are given as arguments to the function that runs the query. I need the DB to return the vec
value, regardless of whether a matching percentile
is found. It is used whenever found. I found some information on how left joins can be done in Mongo but none of the examples weren't even close to what I was looking.
Does someone know how to make such query in Mongo? Is it even possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论