-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"Advanced" search #1218
"Advanced" search #1218
Conversation
@patrick-gleeson Does this allow filtering/searching on associations? For example, could I use it to view all records that belong to a certain parent record? Thanks for taking the time to implement this. We recently added Administrate to our project and advanced searching is something we were planning on adding ourselves. |
@conradbeach In its current form it doesn't allow specifying associations to search. It might be relatively straightforward to implement that, though - I just haven't done much with associations yet so didn't think to try to support it. |
Any word on getting something like this merged? This would be awesome to have |
Search in Administrate could definitely get some improvement, but perhaps not as super-smart default option, but rather by providing an easy way to provide your own. The problem with implementing anything is that different people expect search to work differently in different situations. Take this PR as an example. When you search for Therefore I hesitate to accept any specific changes. In my mind, search should be something for which Administrate provides a bare minimum default (eg: all words across all searchable fields, perhaps with quoted phrases), and users would provide their own custom algorithm by overriding controllers. Currently, search is implemented in
Line 8 is the key. It will take the search query and return some results based on it. If you override this, you can implement whichever search you wish. A simple first approach would be to move this line to a separate method in the same controller. This new method can read the query params (line 7) and perform the search (line 8), returning the results. Once a separate method, it should be more readily available for users to override. Would anyone be up for providing a PR that does just that? (Meanwhile, I'm afraid I'm going to close this PR for the reasons I explain above). |
Hello @pablobm , I'm rather new on administrate and was looking to have some kind of elasticsearch/searchkick integration on it. I understand your solution could help with that? |
I don't know anything about searchkick, but I'm going to guess that yes, it should work. To override Administrate as I explain above, you can edit However bear in mind that you'll have to double check that things still work whenever you upgrade Administrate. We change the implementation of controllers, templates, etc every now and then, and this may cause an incompatibility with your overrides, which will need to be updated. |
Forgive a rather presumptuous PR. I know that #157 is open and there has not been a general agreement on exactly what smart searching would look like.
I just needed more advanced search functionality for a site I'm building, and so I built what I need, and I want to see if anyone else would find it useful.
How this works:
Suppose you have a
User
class with the following in its Administrate dashboardSearch term:
name:Steve
name
fieldSearch term:
name:Steve example
name
field and 'example' in everything searchable except thename
fieldSearch term:
name:'Steve Jones'
name
fieldSearch term:
activated:true
activated
set totrue
Search term:
email:example.com name:"Steve Jones" activated:false hoopla
email
matches 'example.com',name
matches 'Steve Jones',activated
is set totrue
, and it will ignore 'hoopla' because there are no fields left for it to search.I look forward to any thoughts and feedback!