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
namefield
Search term: name:Steve example
- This will search for 'steve' in the
namefield and 'example' in everything searchable except thenamefield
Search term: name:'Steve Jones'
- This will search for 'steve jones' in the
namefield
Search term: activated:true
- This will search for records with
activatedset totrue
Search term: email:example.com name:"Steve Jones" activated:false hoopla
- This will search for records where
emailmatches 'example.com',namematches 'Steve Jones',activatedis 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!