951
edits
(Add MongoDB dump section) |
(List all fields used in the database) |
||
Line 201: | Line 201: | ||
# Official csv export fields are coming from @export_fields variable in /lib/ProductOpener/Config_off.pm | # Official csv export fields are coming from @export_fields variable in /lib/ProductOpener/Config_off.pm | ||
mongoexport -d off -c products --type=csv --fieldFile official_csv_export_fields.txt -q '{"countries_tags": "en:germany"}' --limit 5 --quiet | mongoexport -d off -c products --type=csv --fieldFile official_csv_export_fields.txt -q '{"countries_tags": "en:germany"}' --limit 5 --quiet | ||
</pre> | |||
==== List all fields used in the database ==== | |||
<pre> | |||
# Open Food Facts database contains hundreds of fields. | |||
# An easy way to list them all is to use "variety" Schema Analyzer | |||
# 1. Install "variety" | |||
git clone https://github.com/variety/variety.git | |||
# 2. Use it | |||
cd ./variety | |||
# Analyzing can be very long (hours). You can restrict the analysis to a small number | |||
time mongo off --eval "var collection = 'products', limit = 1000" variety.js > off_schema_1000.txt | |||
# (17 s) | |||
time mongo off --eval "var collection = 'products', limit = 10000" variety.js > off_schema_10000.txt | |||
# (3 minutes) | |||
</pre> | </pre> |