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

API search by "tags" is not returning all components #750

Closed
balbet opened this issue Oct 30, 2024 · 4 comments
Closed

API search by "tags" is not returning all components #750

balbet opened this issue Oct 30, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@balbet
Copy link

balbet commented Oct 30, 2024

Describe the bug

We are using the "Tags" field to store our internal component part number reference. Several components might have the same reference, because they could be equivalent (for example, 2 resistors with the same value, package and tolerance, but with different MPN). It's nice that we can add several tags, the problem comes when we try to retrieve them using the API:

https://our_database/api/parts?tags=Z05959

This only returns the component that matches exactly with the tag Z05959. I can see it in this format the JSON:
"tags":"Z05959"
But the component that has 2 tags was stored as comma separated. I can see it in this format the JSON:
"tags":"Z06108,Z05959"

So, my API request doesn't return the last component. The only way to get it is sending this request:
https://our_database/api/parts?tags=Z06108,Z05959

But of course, this is not an option because we don't know the other reference.

Expected behavior

The expected behavior would be that we get all the components where the tag matches in each comma separated string, and not the entire string. This works fine when the search is done using the web:

https://our_database/en/parts/search?keyword=Z05959&name=1&category=1&description=1&mpn=1&tags=1&storelocation=1&comment=1&ipn=1&ordernr=1

That's why we thing the API behaviour is a bug.

Thanks!

@balbet balbet added the bug Something isn't working label Oct 30, 2024
jbtronics added a commit that referenced this issue Nov 4, 2024
This makes the process of filters more easily and intuitive. This fixes issue #750
@jbtronics
Copy link
Member

In general, these text filters work by trying to match the text exactly. You need to add LIKE wildcards (% for multiple characters, and _ for one character) to find also substrings.

The way the tags are stored internally makes it indeed a bit difficult to filter this. I have added an special filter for the tags tag, which does all the required queries in background. So now you can just supply the tag and you will receive all parts which contains have this tag.

@balbet
Copy link
Author

balbet commented Nov 11, 2024

Perfect, thanks Jan! So, when you say "I have added an special filter...", is this fix already available? Or should we wait until the next version release?

Thanks!

@jbtronics
Copy link
Member

It's part of the already released Part-DB 1.14.3

@balbet
Copy link
Author

balbet commented Nov 11, 2024

Great, thanks for your fast support! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants