Asking for REST API search2 example

Need help? Post your questions here.

Moderator: moderators

Asking for REST API search2 example

Postby Scrofula » Mon Mar 08, 2021 1:03 pm

Hi,

Does anyone have an example of the query parameter for a search2 API call? I can't find any documentation and am currently getting nothing back. A picture paints a thousand words, as they say.
Scrofula
 
Posts: 5
Joined: Sat Mar 04, 2017 3:17 pm

Re: Asking for REST API search2 example

Postby acroyear » Thu Mar 11, 2021 6:14 pm

https://myserver/rest/search2.view?
artistCount=20&artistOffset=0&albumCount=30&albumOffset=0&songCount=100&songOffset=0&query=fred%2A&
v=1.15.0&f=json&c=SubFirePL&u=subfire&s=seed&t=token

where seed and token are from the password encoding as described in the API documentation. v is my api version. f=json means give the reply in json format (alternative is xml). remove newlines, of course. i put those in to make it readable.

For the next page of data, simply increment your offset by the number returned, so the second page of songs would be songOffset=100 (or maybe 101 - i haven't done much here to need paging to know if it starts the first one at 0 or 1).

In the case of artist and album, what you actually have is the ID to call getMusicDirectory on (not getArtist or getAlbum - use search3 for ID3 info, but the params are the same). The songs are complete so you don't need to call getSong() on the info you have.
--
Joe Shelby
http://subfiresuite.com/
http://subfireplayer.net/
User avatar
acroyear
 
Posts: 721
Joined: Wed Mar 27, 2013 8:05 pm
Location: Northern, VA

Re: Asking for REST API search2 example

Postby Scrofula » Sat Mar 13, 2021 3:34 pm

Hi Joe,

Thanks for your reply. I'm actually after more detail on the format of the query= parameter. I believe it is a Lucene query. Am I right in thinking you can only search on Album, Artist and Song? I was hoping to search on Path as I know the database has an index on Path?
Scrofula
 
Posts: 5
Joined: Sat Mar 04, 2017 3:17 pm

Re: Asking for REST API search2 example

Postby acroyear » Sat Mar 13, 2021 4:47 pm

i've never tried anything other than just a straight string query. It is Lucene behind the scenes, but i haven't tried to experiment with the syntax options (other than wildcards) to see how more precise one can get. It may be that it is already doing an extensive amount of work on the search string and so your own syntax simply becomes part of the string it is looking for and likely produce no results. I have the old source codes from the last GPL version tucked away somewhere but I haven't looked in detail at that part at all.

As far as the return value goes for non-id3 Search2 - an "Album" is just a folder that happens to have song files in it. An "Artist" is one level above that. Folders above that level don't show up in search results at all.
--
Joe Shelby
http://subfiresuite.com/
http://subfireplayer.net/
User avatar
acroyear
 
Posts: 721
Joined: Wed Mar 27, 2013 8:05 pm
Location: Northern, VA


Return to Help

Who is online

Users browsing this forum: No registered users and 25 guests