javahttpmusicbrainz

Musicbrainz query case sensitive?


I'm running a Java application that queries the Musicbrainz database for info and I ran into a peculiar problem. The query that my application builds (using java.net.URL.URL) is as follows:

http://musicbrainz.org/ws/2/recording?query=%22Gilt+Complex%22+AND+artistname%3A+%22Sons+And+Daugthers%22

The above query returns an empty response:

<metadata xmlns="http://musicbrainz.org/ns/mmd-2.0#" xmlns:ext="http://musicbrainz.org/ns/ext#-2.0" created="2018-04-25T14:25:36.224Z">
  <recording-list count="0" offset="0"/>
</metadata>

However, if I change the AND to lower case, the query works properly:

http://musicbrainz.org/ws/2/recording?query=%22Gilt+Complex%22+and+artistname%3A+%22Sons+And+Daugthers%22

returns:

<metadata xmlns="http://musicbrainz.org/ns/mmd-2.0#" xmlns:ext="http://musicbrainz.org/ns/ext#-2.0" created="2018-04-25T14:25:36.224Z">
  <recording-list count="526823" offset="0">
    ...
  </recording-list>
</metadata>

The same thing happens if I copy&paste the queries into Chrome. This hasn't happened to me with other songs yet. Can anyone explain what is going on here?


Solution

  • The query is case-sensitive, in the essence that "AND" as a keyword is in all caps. Your first query returns no results, because:

    "Gilt Complex" AND artistname="Sons and Daugthers" has no results.

    Your second query has several hundred thousand results because it is translated into:

    "Gilt Complex" OR and OR artistname="Sons and Daugthers"

    The last term in the query doesn't apply to anything and is simply an exclusion. Searching only for "and" in this case yields 526821 results, which matches what we observed earlier.