extending search on a model #9185
-
Hi there, I'm trying to extend the internal search to work also on a model. I've followed the instructions found here: My model implements the searchable:
I have a class that extends a provider:
The provider is registered
and the search config is updated:
I debugged and placed some log traces and I notice that the FeedProvider methods are not executed during a search even if I'm sure that the FeedProvider::register() is called |
Beta Was this translation helpful? Give feedback.
Replies: 11 comments 6 replies
-
I see you're using Runway - is there any reason you're not using Runway's built-in search functionality? |
Beta Was this translation helpful? Give feedback.
-
Not really. I just tested Runway to manage the model in the CP and didn't know that I can also use it for the search. Thank you; I'll definitely try it. However, I would also like to understand how to extend the search functions using only Statamic. |
Beta Was this translation helpful? Give feedback.
-
I quickly tested also with runway but I still get no results
|
Beta Was this translation helpful? Give feedback.
-
I've just ran through the custom searchables documentation quickly and was able to get a custom searchable working. For clarity, here's all my search-related code. I think the only difference is that I had to add methods to handle augmentation, whereas your model doesn't have any of those models (Runway handles augmentation for you via it's A couple of questions for you:
|
Beta Was this translation helpful? Give feedback.
-
First of all thanks for your time and effort... I'm using a simple antlers view to show the result for now (later I would like to use a typical controller + blade flow):
No results at all... nothing is found on the Feed model with both the ways |
Beta Was this translation helpful? Give feedback.
-
Hi again. I attempted to import and copy your 'post' example, but I encountered an error when running a search: Searchable App\Models\Post must implement Statamic\Contracts\Query\ContainsQueryableValues it is strange that you didn't get the same error, anyway I updated your model to match mine related to 'feeds,' adding what is required (QueryableValues). Here's the new version:
ok, now no more error, but still no results found... any ideas? thanks! |
Beta Was this translation helpful? Give feedback.
-
I have around another installation with this example: so I linked the same db and tried to import your 'posts' example files (with my changes for the ContainsQueryableValues error) , and it still doesn't work (I mean, no results are found)... so, wait... could be an issue related to the multilanguage/multisite maybe? |
Beta Was this translation helpful? Give feedback.
-
I think the quicker way would be to install this: https://statamic.com/starter-kits/statamic/multisimplicity because mine contains a lot of crappy tests and experiments and some private data related to our users |
Beta Was this translation helpful? Give feedback.
-
Okay, I can confirm that the issue is definitely related to the multisite/multilanguage setup. In the So, what's the next step? Is this a bug? |
Beta Was this translation helpful? Give feedback.
-
Hey! 👋 I've just spun up a quick site using the Multisimplicity starter kit for testing and I've managed to get search working with both Runway's built-in search stuff & using custom searchables. I've pushed up the two implementations on different branches so you can compare against them: https://github.com/duncanmcclean/statamic-cms-9185/branches I didn't have any issues implementing search with Runway's built-in searchable, everything worked as per the docs. However, when using a custom searchable, I did have to add https://github.com/duncanmcclean/runway/blob/5.x/src/Search/Searchable.php#L39-L41 When you're using a custom searchable, you will need to implement both the Hopefully that's helpful for you and you're able to finally get search results returned! 🚀 |
Beta Was this translation helpful? Give feedback.
-
Thank you so much, indeed that Just one final question... now I wanna use a normal laravel route with controller and laravel blade. Which is the right way to query the Search facade to replicate that antlers queries?
thanks! |
Beta Was this translation helpful? Give feedback.
Hey! 👋
I've just spun up a quick site using the Multisimplicity starter kit for testing and I've managed to get search working with both Runway's built-in search stuff & using custom searchables.
I've pushed up the two implementations on different branches so you can compare against them: https://github.com/duncanmcclean/statamic-cms-9185/branches
I didn't have any issues implementing search with Runway's built-in searchable, everything worked as per the docs.
However, when using a custom searchable, I did have to add
sites="*"
to the{{ search:results }}
tag for any results to be returned. I think Runway does this to workaround this issue in its searchable:https://github.com/duncanmccle…