Created by: patrick-gleeson
Forgive a rather presumptuous PR. I know that #157 (closed) 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 dashboard
ATTRIBUTE_TYPES = {
name: Field::String,
email: Field::String,
activated: Field::Boolean
}
Search term: name:Steve
- This will search for 'steve' in the
name
field
Search term: name:Steve example
- This will search for 'steve' in the
name
field and 'example' in everything searchable except thename
field
Search term: name:'Steve Jones'
- This will search for 'steve jones' in the
name
field
Search term: activated:true
- This will search for records with
activated
set totrue
Search term: email:example.com name:"Steve Jones" activated:false hoopla
- This will search for records where
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!