Search across multiple fields using the meteor-easy-search method

I am trying to implement a search on two db fields using the meteor-easy-search package, however, I cannot find a way to do this. Here is the problem:

I have a diagram:

{ name: String, location: String } 

I have two input fields in my form:

 <input type="text" name="name"> <input type="text" name="location"> 

EasySearch provides a way to search by only one value:

  EasySearch.search('people', name, ..... 

Is there a way to pass an Object method to search, so I can write my own query in EasySearch.createSearchIndex ()?

In addition, I will need to convert the โ€œlocationโ€ to a geo-spiral index and search for โ€œname within the radius of this locationโ€

I know that this can be done directly with MongoDB or ElasticSearch, but I would like, if possible, to roll using meteor-easy-search.

+5
source share
1 answer

From the meteor simple search documentation, you can initialize the default query in the EasySearch.createSearchIndex() call, and also add several search fields, for example:

 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; } }); 
+1
source

All Articles