matteodem / meteor-easy-search

Easy-to-use search for Meteor with Blaze Components
MIT License
436 stars 68 forks source link

mongo aggregate with easysearch #598

Closed steven-tib closed 7 years ago

steven-tib commented 7 years ago

Hi @matteodem,

I've just read the posts concerning mongo aggregate feature and especially this one #561 where you mention that aggregate function has to be called outside of easysearch and it's out of the scope of ES package. I apologize for still asking here but need just a hint to get on the right track. How can I use the aggregate function on the result of a search with Easysearch? Let me try to quickly explain what I'm trying to achieve:

On the image below I have one text field where I use ES with a MongoTextIndex engine to execute a full-text search. I would like then to narrow down the search based on the sliders values below ($gte / $lte for each slider)

capture d ecran 2017-04-04 21 54 42

The aggregate should look like this:

  db.fibers.aggregate([{ 
    $match: { 
      $text: { $search: "abcdef" } } //full-text search
    },      
  { 
    $match: {'mechanicalProperties.tensileModulus_metric': { $gte: 900.0 }}  // slider search
  }])

Could you please give me one or two hints on how to achieve this? maybe not necessarily with aggregates if there is another easier solution? Many thanks

steven-tib commented 7 years ago

Ok I finally used a solution without easysearch. I used this package: jcbernack:reactive-aggregate and rebuilt the search around this aggregate publication. If anyone needs more details let me know and I'll try to help.