Difference between revisions of "Product Opener/Installation/Issues"

From Open Food Facts wiki
Jump to navigation Jump to search
(some issues - list of tags not returned)
(No difference)

Revision as of 09:52, 20 January 2015

Dotted fields in MongoDB

Problem:

MongoDB 2.6 complains about fields that contains dots. Before 2015, Product Opener stored some backup versions of some fields by appending a dot and some string.

"The dotted field 'countries.20131226' in 'countries.20131226' is not valid for storage."

Resolution:

Those fields can be safely removed. (done in update_all_products_from_dir_in_mongodb.pl)

=== List of tag values (e.g. list of categories)

Problem:

With MongoDB 2.6, the aggregate command used to list all values of tags such as categories does not return the same structure.

in Display.pm:

        eval {
                $results = $products_collection->aggregate( $aggregate_parameters );
        };
 -e: Not an ARRAY reference at /home/off/cgi//Blogs/Display.pm line 789.
display.pl : query_string: /lieux-de-fabrication
analyze_request : query_string 1 : /lieux-de-fabrication
analyze_request : query_string 2 : /lieux-de-fabrication
analyze_request : query_string 3 : lieux-de-fabrication
Display::analyze_request - last component - lieux-de-fabrication - plural? manufacturing_places
Display::analyze_request - list of tags - groupby: manufacturing_places
Display::analyze_request - lc: fr lang: fr text:  - product:  - tagtype/tagid: / - tagtype2/tagid2: / - groupby: manufacturing_places
display.pl blogid:  tagid:  urlsdate:  urlid:  user:  query:
Display.pm - display_list_of_tags - query:
$VAR1 = {
          'countries_tags' => 'en:france',
          '_tags' => undef
        };

Display.pm - display_list_of_tags - aggregate_parameters:
$VAR1 = [
          {
            '$match' => {
                          'countries_tags' => 'en:france',
                          '_tags' => undef
                        }
          },
          {
            '$unwind' => '$manufacturing_places_tags'
          },
          {
            '$group' => {
                          'count' => {
                                       '$sum' => 1
                                     },
                          '_id' => '$manufacturing_places_tags'
                        }
          },
          {
            '$sort' => {
                         'count' => -1
                       }
          }
        ];

Display.pm - display_list_of_tags - aggregate query done
Display.pm - display_list_of_tags - results:
$VAR1 = bless( {
                 '_database' => bless( {
                                         '_connection' => bless( {
                                                                   'w' => 1,
                                                                   'query_timeout' => 30000,
                                                                   'find_master' => 0,
                                                                   'db_name' => 'admin',
                                                                   'auto_reconnect' => 1,
                                                                   '_servers' => {},
                                                                   'ts' => 0,
                                                                   'right_port' => 27017,
                                                                   'wtimeout' => 1000,
                                                                   'port' => 27017,
                                                                   'left_port' => 27017,
                                                                   'host' => 'localhost:27017',
                                                                   'max_bson_size' => 16777216,
                                                                   'timeout' => 20000,
                                                                   'auto_connect' => 1
                                                                 }, 'MongoDB::Connection' ),
                                         'name' => 'off'
                                       }, 'MongoDB::Database' ),
                 'name' => 'products.aggregate'
               }, 'MongoDB::Collection' );

[Tue Jan 20 10:23:20 2015] [error] [Tue Jan 20 10:23:20 2015] -e: Not an ARRAY reference at /home/off/cgi//Blogs/Display.pm line 789.\n

Expected:

Display.pm - display_list_of_tags - aggregate query done
Display.pm - display_list_of_tags - results:
$VAR1 = [
          {
            'count' => 3055,
            '_id' => 'france'
          },
          {
            'count' => 542,
            '_id' => 'bretagne'
          },
..