Skip to content

Commit

Permalink
fix(artist): fix artist fuzzy search
Browse files Browse the repository at this point in the history
Musicbrainz officially uses the "artist" field to search for artists,
and this has been giving incorrect results when trying to fuzzy search
through the "name" field.

See #23 for more details.
  • Loading branch information
ritiek authored and oknozor committed Jun 15, 2021
1 parent c9bee6f commit cb1a309
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ fn main() {
.execute();

let artists_on_in_utero_release = artists_on_in_utero_release.unwrap();

artists_on_in_utero_release
.entities
.iter()
Expand All @@ -110,7 +110,7 @@ fn main() {
musicbrainz_rs::config::set_user_agent("my_awesome_app/1.0");

let query = Artist::query_builder()
.name("Miles Davis")
.artist("Miles Davis")
.and()
.country("US")
.build();
Expand Down
4 changes: 2 additions & 2 deletions crates-io.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ fn main() {
.execute();

let artists_on_in_utero_release = artists_on_in_utero_release.unwrap();

artists_on_in_utero_release
.entities
.iter()
Expand All @@ -110,7 +110,7 @@ fn main() {
musicbrainz_rs::config::set_user_agent("my_awesome_app/1.0");

let query = Artist::query_builder()
.name("Miles Davis")
.artist("Miles Davis")
.and()
.country("US")
.build();
Expand Down
2 changes: 1 addition & 1 deletion examples/search_artist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ fn main() {
musicbrainz_rs::config::set_user_agent("my_awesome_app/1.0");

let query = Artist::query_builder()
.name("Miles Davis")
.artist("Miles Davis")
.and()
.country("US")
.build();
Expand Down
1 change: 1 addition & 0 deletions src/entity/artist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ pub struct Artist {
pub id: String,

/// The official name of an artist, be it a person or a band.
#[query_builder_rename = "artist"]
pub name: String,

/// The sort name is a variant of the artist name which would be used when sorting artists by
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ pub struct BrowseQuery<T>(Query<T>);
/// # fn main() -> Result<(), Error> {
/// # use musicbrainz_rs::entity::artist::Artist;
/// let query = Artist::query_builder()
/// .name("Miles Davis")
/// .artist("Miles Davis")
/// .and()
/// .country("US")
/// .build();
Expand Down
2 changes: 1 addition & 1 deletion tests/artist/artist_search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::{thread, time};
#[test]
fn should_search_artist() {
let query = Artist::query_builder()
.name("Nirvana")
.artist("Nirvana")
.and()
.artist_type("Group")
.build();
Expand Down

0 comments on commit cb1a309

Please sign in to comment.