Freesound API search suddenly always returns the same items

53 views
Skip to first unread message

Hanna Becker

unread,
Dec 20, 2023, 6:56:48 AM12/20/23
to Freesound API
We noticed today that the freesound search we integrated in our app suddenly always returns the same items, no matter what search term we use.

Below is the JS code we use to search.

It seems to be related to the tag filter, because if I remove it, the search results change with the query. However, the search query as we have it worked fine up until at least December 13 (we have tests for it in our CI pipeline that still passed on that day). We haven't touched that code for a couple of months.

const FreeSound = require('freesound-client').default;
const freeSound = new FreeSound();

freeSound.setToken(
<API_TOKEN>);

const { searchTerm } = event.arguments;

const response = await freeSound.textSearch('', {
  page: 1,
  filter: `duration:[1.0 TO 15.0]AND(license:"Creative Commons 0")AND(original_filename:(*${searchTerm}*))OR(tag:(*${searchTerm}*))`,
  sort: 'rating_desc',
  fields: 'id,duration,name,license,previews,type,tags',
});

console.log(JSON.stringify(response));

Frederic Font Corbera

unread,
Dec 20, 2023, 9:36:22 AM12/20/23
to freeso...@googlegroups.com
Hi,

This seems to be a bug we introduced yesterday after some changes in the search engine. We'll work to fix that,
Cheers,

frederic

--
Frederic Font - ffont.github.io
Music Technology Group, UPF - mtg.upf.edu
Freesound - freesound.org



--

---
You received this message because you are subscribed to the Google Groups "Freesound API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to freesound-ap...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/freesound-api/0355a2ee-e9f8-4f10-bb3d-e4c852808d2en%40googlegroups.com.

Frederic Font Corbera

unread,
Dec 21, 2023, 4:17:00 AM12/21/23
to freeso...@googlegroups.com
Hi again,

We've been investigating the issue. If I understand correctly the goal of your query, I would say it is not properly formulated as the parenthesis are not set correctly. I understand that what you want to achieve is to search for sounds which match the query terms either in their name or in their tags, and that they are CC0 license and with a duration of 1 to 15 seconds. Therefore, the overall structure should be "duration_filter AND license_filter AND (matching_filename OR matching_tag)", but currently it is "duration_filter AND (license_filter) AND (matching_filename) OR (matching_tag)". I guess that after our last update of the search engine the interpretation of the parenthesis changed, but if you put the parenthesis correctly, then the query works as expected. So basically your filter shold be:

`duration:[1.0 TO 15.0]AND(license:"Creative Commons 0")AND(original_filename:(*${searchTerm}*) OR tag:(*${searchTerm}*))`


That said, I think a better way to achieve similar results is to set the "query" paramter to the search term, and then use the "filter" parameter only for the duration and license filters.

Let me know if that works,

Cheers,


frederic



--
Frederic Font - ffont.github.io
Music Technology Group, UPF - mtg.upf.edu
Freesound - freesound.org

Hanna Becker

unread,
Dec 21, 2023, 5:08:21 AM12/21/23
to Freesound API
Hi Frederic,

You're right, I didn't notice the parantheses are grouped wrongly. Thanks for pointing that out! How strange that it ever worked like this.

It works fine again with the query you proposed.

About your other suggestion, I've tried that before, but can't seem to produce good results with it.

E.g. trying this with the searchTerm "insomnia"...
const response = await freeSound.textSearch(`*${searchTerm}*`, {
page: 1,
filter: `duration:[1.0 TO 15.0] AND (license:"Creative Commons 0")`,
sort: 'rating_desc',
fields: 'id,duration,name,license,previews,type,tags',
});

...I only get one search result, whereas with the other query I get 4 which look like good matches. From the search results, the impression I get is that the query parameter looks for an exact match of the word, rather than also matching for terms where it's included, like "insomniac". (I also tried it like this, btw, with the same result:  freeSound.textSearch(searchTerm, ...)

From the API docs, however, I understand that the query parameter should work as an inclusion filter: "Therefore, searching for query=123 will find you sounds with id 1234, sounds that have 1234 in the description, in the tags, etc." (https://freesound.org/docs/api/resources_apiv2.html#search-resources).

Cheers,

Hanna

Reply all
Reply to author
Forward
0 new messages