Try 30 days of free premium.

Search Show endpoint basic question

setblue wrote 4 years ago: 1

Hello all,

Firstly, as a newcomer, I’d like to thank TVMaze for this great API. I’m dazzled by how fast this API is compared to what I tried before.

Now for the question : I´m playing a bit with the Search Show end point and I don’t understand how the query is handled regarding spaces. I‘m working on a search as you type engine and I ran some test that can easily be reproduced in a browser : when I query, let’s say, « Buffy the vampire slayer » as the user is typing the keywords, I noticed that if tou query « Buffy t », you get no response at all (empty json) - although you do get some response for « Buffy » and « Buffy th ». It seems that when you get to the point you have only 1 character right after a space, the API is not providing any result. My test URL encode the spaces - they are replaced with %20. I tried to replace them by « + », to no avail.

Do you guys know why is that?

Thanks,


gazza911 wrote 4 years ago: 1

This is just due to how the search works (tl;dr at bottom for suggestion).

It doesn't directly check if your search string is found in any results, but does fuzzy searching.

In short, what it's doing is seeing how close each individual word in your search query is to a word in the show.

That's why if I misspelt it and put "slayee" instead of "slayer" it can recognise that it's close enough. With longer words, more characters can be different as the percentage wrong will be less.

As a simple way of explaining this, if I search for "Buffy vampi slayee" I'll still get results. If I search for "Buffy slayee vampi" I'll still get the exact same results with the same score (relevance) despite the order of the words being switched.

tl;dr if you want exact string matching, you're going to have to cache the results that you get and then when you continue to type, check if each cached result contains the new query exactly and if so re-display it.

setblue wrote 4 years ago: 1

gazza911 wrote:
This is just due to how the search works (tl;dr at bottom for suggestion).

It doesn't directly check if your search string is found in any results, but does fuzzy searching.

In short, what it's doing is seeing how close each individual word in your search query is to a word in the show.

That's why if I misspelt it and put "slayee" instead of "slayer" it can recognise that it's close enough. With longer words, more characters can be different as the percentage wrong will be less.

As a simple way of explaining this, if I search for "Buffy vampi slayee" I'll still get results. If I search for "Buffy slayee vampi" I'll still get the exact same results with the same score (relevance) despite the order of the words being switched.

tl;dr if you want exact string matching, you're going to have to cache the results that you get and then when you continue to type, check if each cached result contains the new query exactly and if so re-display it.

Thanks a lot for your response, I’m gonna work on a cache check mecanism :)


gazza911 wrote 4 years ago: 1

setblue wrote:
Thanks a lot for your response, I’m gonna work on a cache check mecanism :)

No problem.

You may also have to use the shows/x/akas endpoint to get the AKAs for the cached results as the API will also search against AKAs (albeit with a lower score given).

Try 30 days of free premium.