Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Barcode json search url does not always work #2435

Open
Tracked by #5523
aleene opened this issue Oct 15, 2019 · 6 comments
Open
Tracked by #5523

Barcode json search url does not always work #2435

aleene opened this issue Oct 15, 2019 · 6 comments
Labels
API READ All READ APIs include Product, Search… API Issues related to the Open Food Facts API. More specific labels exist & should be used (API WRITE…) 🐛 bug This is a bug, not a feature request. no-issue-activity

Comments

@aleene
Copy link
Contributor

aleene commented Oct 15, 2019

Describe the bug
Finetuning the barcode search url to get only one products breaks down at some stage.

To Reproduce
Try:
https://ssl-api.openfoodfacts.org/code/87176773367xx.json results in 1 product.
https://ssl-api.openfoodfacts.org/code/871767733672x.json results in 0 products. (is valid)

Expected behavior
Should stay 1 product

@aleene aleene added the 🐛 bug This is a bug, not a feature request. label Oct 15, 2019
@stephanegigandet
Copy link
Contributor

stephanegigandet commented Oct 15, 2019

In fact this is working as intended, so that we don't have a huge amount of different entries in the /codes facet. We had the x, xx and xxx entries before, but it rendered the facet unusable, so they were removed.

	while ($code =~ /^\d/) {
		# only keep codes with 3 xx at the end
		if ($code =~ /xxx$/) {
			push @codes, $code;
		}
		$code =~ s/\d(x*)$/x$1/;
	}

	$product_ref->{codes_tags} = \@codes;

@aleene
Copy link
Contributor Author

aleene commented Oct 15, 2019

Is confusing if someone does a search and nothing happens any more.

@stephanegigandet
Copy link
Contributor

It's not a search though. If you have the barcode, then you can use the API to get the product directly, without using the codes facet. The facet is intended to group products from the same brand, it's not for search.

@aleene
Copy link
Contributor Author

aleene commented Oct 15, 2019

The app uses it to drill down the list of results, with each addition of a digit. So it is a search there.

@stephanegigandet
Copy link
Contributor

I wasn't aware that the app used the facet to do that, it's an interesting use. I'm not sure if that use case is worth the extra load in the database and server though. Those queries are relatively stressfull for the server, and making one for each digit typed is a lot. Using an offline db of codes may be better.

@teolemon teolemon added API Issues related to the Open Food Facts API. More specific labels exist & should be used (API WRITE…) API READ All READ APIs include Product, Search… labels Nov 27, 2019
@github-actions
Copy link
Contributor

github-actions bot commented Jul 8, 2020

Stale issue message

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API READ All READ APIs include Product, Search… API Issues related to the Open Food Facts API. More specific labels exist & should be used (API WRITE…) 🐛 bug This is a bug, not a feature request. no-issue-activity
Projects
Status: To discuss and validate
Development

No branches or pull requests

3 participants