I have a few gigs of data stored as json, is it best to load them into mongodb or couchdb (probably on a remote host like Mongolab), a flat-file json db like http://fatfreeframework.com/jig, parse the files directly on the server using PHP (or Node, etc) or some other method? The files are huge, it wouldn't be good to have to load them into memory but I'm open to everything.
我有一些数据存储为json,最好将它们加载到mongodb或couchdb(可能在像Mongolab这样的远程主机上),像http://fatfreeframework.com/jig这样的平面文件json db,解析使用PHP(或Node等)或其他方法直接在服务器上的文件?这些文件很庞大,将它们加载到内存中并不好,但我对所有内容都开放。
1 个解决方案
#1
3
It sounds like you want to:
听起来你想:
- Store a lot of data in JSON format
- 以JSON格式存储大量数据
- Query for a specific JSON document
- 查询特定的JSON文档
- Return a small portion of the matching document
- 返回匹配文档的一小部分
I can't speak for CouchDB, but this is pretty easy in MongoDB:
我不能代表CouchDB,但在MongoDB中这很容易:
-
load your JSON documents into MongoDB using
mongoimport
.使用mongoimport将您的JSON文档加载到MongoDB中。
-
Index the fields you'll be querying on using
ensureIndex()
使用ensureIndex()索引要查询的字段
-
Use the
find()
command to query for the desired document (criteria
parameter) and return the target key subset (projection
parameter)使用find()命令查询所需文档(条件参数)并返回目标键子集(投影参数)
The main limitation here is the size of your "huge" JSON documents. MongoDB limits each document to 16MB, so if they're larger than that you'll need to strip out some data or do some fancy tricks to make it work. If they do fit under that limit, then MongoDB should be a pretty good way to meet your requirement.
这里的主要限制是“巨大的”JSON文档的大小。 MongoDB将每个文档限制为16MB,因此如果它们大于那么你需要删除一些数据或做一些花哨的技巧来使其工作。如果它们确实符合该限制,那么MongoDB应该是满足您要求的一种非常好的方式。
#1
3
It sounds like you want to:
听起来你想:
- Store a lot of data in JSON format
- 以JSON格式存储大量数据
- Query for a specific JSON document
- 查询特定的JSON文档
- Return a small portion of the matching document
- 返回匹配文档的一小部分
I can't speak for CouchDB, but this is pretty easy in MongoDB:
我不能代表CouchDB,但在MongoDB中这很容易:
-
load your JSON documents into MongoDB using
mongoimport
.使用mongoimport将您的JSON文档加载到MongoDB中。
-
Index the fields you'll be querying on using
ensureIndex()
使用ensureIndex()索引要查询的字段
-
Use the
find()
command to query for the desired document (criteria
parameter) and return the target key subset (projection
parameter)使用find()命令查询所需文档(条件参数)并返回目标键子集(投影参数)
The main limitation here is the size of your "huge" JSON documents. MongoDB limits each document to 16MB, so if they're larger than that you'll need to strip out some data or do some fancy tricks to make it work. If they do fit under that limit, then MongoDB should be a pretty good way to meet your requirement.
这里的主要限制是“巨大的”JSON文档的大小。 MongoDB将每个文档限制为16MB,因此如果它们大于那么你需要删除一些数据或做一些花哨的技巧来使其工作。如果它们确实符合该限制,那么MongoDB应该是满足您要求的一种非常好的方式。