I'm trying to implement a search by two db fields using meteor-easy-search package, however, I can't seem to find a way of doing it. Here is the problem:
I have a schema:
{
name: String,
location: String
}
I have two input fields on my form:
<input type="text" name="name">
<input type="text" name="location">
EasySearch provides a way of searching only by a single value:
EasySearch.search('people', name, .....
Is there a way I can pass an Object to search method, so I can write my own 'query' inside of EasySearch.createSearchIndex()?
Moreover, I will need to convert "location" into a geo-spiral index and search for "a name within a radius of this location"
I know this can be done directly with MongoDB or ElasticSearch, but I would like to roll with meteor-easy-search, if possible.
From the meteor-easy-search documentation, you can initialize a default query in the EasySearch.createSearchIndex()
call and also add several search fields, like this:
EasySearch.createSearchIndex('people', {
'field' : ['name', 'location'],
'collection' : People,
'limit' : 20,
'use' : 'elastic-search'
'props' : {
'anyField' : true
},
'query' : function (searchString, opts) {
// Default query that is used for searching
var query = EasySearch.getSearcher(this.use).defaultQuery(this, searchString);
return query;
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With