marcreichel / igdb-laravel

Simplify the integration of the IGDB API into your Laravel app. Including IGDB webhook support.
https://marcreichel.dev/docs/igdb-laravel
MIT License
104 stars 22 forks source link

Add more info in the Readme on how to search with "Like" #45

Closed adzay closed 2 years ago

adzay commented 2 years ago

Hi,

Can you add more in your readme to help search names with igdb filters (lower case, '*' etc)? Like the "whereLike" solution you posted here:

33

I was struggling with finding names with capitals and special characters for a while before i found your answer in the above link. Putting in the readme can help others

Also, if not a lot of work, can you put an example on how to make it as "Fuzzy search" as possible? e.g. Right now i split my search term by space and put each entry into multiple "orWhereLike"s. Maybe you know a more efficient way?

marcreichel commented 2 years ago

Hi @adzay,

Your wish is my command. 😉 I've just released v3.1.0 with updated docs for whereLike and a new fuzzySearch method which (for now) does just the same as you doing right now and combines multiple "orWhereLike"s. So this method is just here for making your life as a developer (and others) easier so you do not have to implement this "cumbersome" process yourself (over and over again). 🙂 A more efficient way of searching is by just using the search method but keep in mind this method only works for Character, Collection, Game, Platform and Theme.

marcreichel commented 2 years ago

Sadly a better and more efficient fuzzy search technically is not possible at the time of writing.

adzay commented 2 years ago

Hi @adzay,

Your wish is my command. 😉 I've just released v3.1.0 with updated docs for whereLike and a new fuzzySearch method which (for now) does just the same as you doing right now and combines multiple "orWhereLike"s. So this method is just here for making your life as a developer (and others) easier so you do not have to implement this "cumbersome" process yourself (over and over again). 🙂 A more efficient way of searching is by just using the search method but keep in mind this method only works for Character, Collection, Game, Platform and Theme.

Thank you! The updated docs is exactly what is needed! Especially the fuzzy search you made!

Regarding the 'search' method. Initially I used Game::search('Call Of Duty'), but it was not clear how to disable sensitivity or do that fuzzy search method I mentioned above: Is something like the below possible?:

Game::search('Call Of Duty',false)->orSearch('Call*',false)->orSearch('*of*',false)->orSearch('*Duty*,false)

marcreichel commented 2 years ago

I'm glad the docs helped you out 🙂

For my understanding, the search of the IGDB API does exactly what you need. It is case insensitive by default and the search is "fuzzy" as well where the results are sorted by relevance. So at first come results matching all words of your search query and afterwards results matching less words of your search query and so on.

So the following should work just fine:

Game::search('Call of Duty')->get();

I'm not on the PC right now but I will check this behavior tomorrow and will get back to you 👍🏼

marcreichel commented 2 years ago

So, I back checked it now. First of: The search method is case insensitive (as you can see in the screenshot below).

image

But sadly the search can not be combined with other where clauses nor multiple searches. (Whereas this is not a problem with this package but a limitation of the IGDB API)

adzay commented 2 years ago

Thank you! i will close this.

Btw, the webhooks CLI (igdb:webhooks:create) doesn't create any webhooks despite saying so. After running igdb:webhooks it says none created.

marcreichel commented 2 years ago

@adzay

Are you sure? 🤔

For me it's working:

image

marcreichel commented 2 years ago

Feel free to open a new issue so we can discuss over there and close this issue right here 👍🏼