Filtering with "-" seems to break search?

35 views
Skip to first unread message

er...@sonicbloomgames.com

unread,
Jun 6, 2017, 9:46:33 AM6/6/17
to Freesound API
With the main Freesound.org website search, we can configure the query to apply to Tags only. This allows us to make use of the '+' and '-' characters to filter results that have/don't have specific tags. Here is an example that shows this in action:


However, attempting to approximate that using the search parameters described in the Resources page returns an HTTP 400 Bad Request response. Here is the example search used:


In the main Freesound.org page, it appears that there's a way to specify "Search by Tag" using the "advanced=1" and "a_tag=1" options. Is there some equivalent in APIv2?

Frederic Font

unread,
Jun 6, 2017, 10:27:35 AM6/6/17
to freeso...@googlegroups.com
Hi Eric,

Yes you can do that, but you are using wrong syntax.
You can specify complex filters using expressions as shown in the examples of the “filter” parameter documentation (http://www.freesound.org/docs/api/resources_apiv2.html#text-search). For your specific case you should do something like:

tag:(piano -cat)

See the url:



Cheers,


frederic


---
Frederic Font
Music Technology Group
Universitat Pompeu Fabra

Freesound | www.freesound.org
Audio Commons | www.audiocommons.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.
For more options, visit https://groups.google.com/d/optout.

er...@sonicbloomgames.com

unread,
Jun 6, 2017, 10:49:00 AM6/6/17
to Freesound API
Hi Frederic,

Thanks for the explanation! I looked over that documentation a number of times and didn't notice any specific instructions on using parenthesis for multiple terms. Indeed, the only place I was able to see the syntax you showed was in the section showing logic operators. Specifically:

Simple logic operators can also be used in filters: 
 
filter=type:(wav OR aiff)
filter
=description:(piano AND note)

Beyond this, the syntax that I'm using for tag inclusion/exclusion is actually described in the query field description. Perhaps it would be useful to have an explicit section to describe the difference/equality between the logic operators (OR/AND/NOT[?]) and mandatory/prohibited operators (+/-)? Further, a section describing searching for multiple tags or multiple terms would be useful (or at least an example, as you provided above).

Thanks so much for the response! Very helpful!

- Eric
Reply all
Reply to author
Forward
0 new messages