openfoodfacts / openfoodfacts-server

Open Food Facts database, API server and web interface - 🐪🦋 Perl, CSS and JS coders welcome 😊 For helping in Python, see Robotoff or taxonomy-editor
http://openfoodfacts.github.io/openfoodfacts-server/
GNU Affero General Public License v3.0
653 stars 383 forks source link

Search request returns an empty array when done on world #9156

Open alexfauquette opened 1 year ago

alexfauquette commented 1 year ago

What

It seems that Switzerland is now independent from the world 😁. At least when doing a search on OFF

I was looking for products that: have an ingredients image, but no ingredients. It failed up to when I got the idea to search for a dedicated country.

Steps to reproduce the behavior

  1. request https://ch.openfoodfacts.org/cgi/search.pl?json=true&fields=code&action=process&tagtype_0=states&tag_contains_0=contains&tag_0=en:ingredients-to-be-completed&tagtype_1=states&tag_contains_1=contains&tag_1=en:ingredients-photo-selected
  2. request https://world.openfoodfacts.org/cgi/search.pl?json=true&fields=code&action=process&tagtype_0=states&tag_contains_0=contains&tag_0=en:ingredients-to-be-completed&tagtype_1=states&tag_contains_1=contains&tag_1=en:ingredients-photo-selected (the same with world.openfoodfacts.org instead of ch.openfoodfacts.org )
  3. See that in the first request, we get elements, and the second one returns {"page":1,"page_size":24,"products":[],"skip":0}

Expected behavior

teolemon commented 1 year ago

I get elements for the 1st requests. You might have been unlucky when you requested. Can we close @alexfauquette ?

alexfauquette commented 1 year ago

I tried again, but it's not better.

I opened the two links in distinct tabs, and ch returns immediatly a response, wherase world loads during 30 seconds for and empty answer

See the recording

teolemon commented 1 year ago
hangy commented 1 year ago

Anything in the server logs? It's a bit weird to have a timeout that produces an empty result array (at least in this case). 🤔

john-gom commented 1 year ago

That particular query creates the following MongoDB query which off-query doesn't currently support:

{
  "$and": [
    {
      "states_tags": "en:ingredients-photo-selected"
    },
    {
      "states_tags": "en:ingredients-to-be-completed"
    }
  ]
}

So this query will be falling back to products_tags in MongoDB. Adding "and" support to off-query should be relatively easy

john-gom commented 1 year ago

Note that @raphael0202 's original queries don't hit off-query at all