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
GNU Affero General Public License v3.0
633 stars 371 forks source link

Create a JSON version of the JQM compact search #554

Closed teolemon closed 6 years ago

teolemon commented 7 years ago

Rationale: 10X improvement in performance for the Android Search URL: http://world.openfoodfacts.org/cgi/search.pl?search_terms=nutella&search_simple=1&action=process&jqm=1

herau commented 7 years ago

I think the API should take care about the Accept request header ( for example application/json instead of using query parameter like json=1).

hangy commented 7 years ago

Rationale: 10X improvement in performance for the Android Search URL: http://world.openfoodfacts.org/cgi/search.pl?search_terms=nutella&search_simple=1&action=process&jqm=1

Do you have a quick overview on how the output should be formatted and in how far it would be different from ?json=1?

I think the API should take care about the Accept request header ( for example application/json instead of using query parameter like json=1).

That would be cool, but some other APIs like OpenSearch do depend on different formats being available at different URLs. In general, I do like the "magic" behind content-negotiation, though. :)

teolemon commented 7 years ago

The same data as ?jqm=1 but in a json format. For simple implementation, it could be a ?simple_json=1 parameter

hangy commented 7 years ago

Could the Android app also use the OpenSearch standard (see #605) or is that not enough information?

herau commented 7 years ago

@hangy do you have any sample of the json output of this api ? don't find any example in #605

hangy commented 7 years ago

There's no JSON, just RSS 2.0 with OpenSearch 1.1, pretty much the same as in the example in the specs.

herau commented 7 years ago

Ok, so no match our JSON format requirement for the android app

teolemon commented 7 years ago

@hangy Here's what the new search looks like (kudos to @herau ) image

teolemon commented 7 years ago

@stephanegigandet @hangy

Search

To sum up:

It will dramatically speed up search in the new Android version for Open Food Facts and Open Beauty Facts.

Product

stephanegigandet commented 7 years ago

Maybe we could just add a fields parameters. e.g. &fields=product_name,brands,quantity

teolemon commented 7 years ago

More modular. Better. +1 :-)

stephanegigandet commented 6 years ago

Added fields parameter, as in the product read API bug #623 :

https://world.openfoodfacts.net/cgi/search.pl?search_terms=nutella&search_simple=1&action=process&json=1&fields=product_name,nutrition_grades_tags

stephanegigandet commented 6 years ago

Also works on facets: https://world.openfoodfacts.net/category/pizzas.json?fields=product_name,categories_tags,ingredients_text,image_front_small_url,nutrition_grades_tags