Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FilterBy on search #37

Closed
Sivli-Embir opened this issue Sep 23, 2014 · 5 comments
Closed

FilterBy on search #37

Sivli-Embir opened this issue Sep 23, 2014 · 5 comments

Comments

@Sivli-Embir
Copy link

@matteodem still loving this package. I am now using this in another app and I need a filter by, ideally on the server for security reasons. I have something close to the following:

//Groups 
{
  users: [userIds]
}
//Items
{
 name: 'name'
 group: groupId
}

Assuming there is not an existing/better way to do this. I would like to do:

EasySearch.createSearchIndex('items', {
  'collection'    : Items,
  'field'         : ['name']
 //filter by magic here? That limits by groups the user has access to
  }
});
//OR (likely easier)
EasySearch.search('items', 'someName', filterBy: 'groupId', function (err, data) {
});
//with some kind of server-side security check
@Sivli-Embir
Copy link
Author

Worth notting that I will likely be using ether elastic-search or mongo-db.

@matteodem
Copy link
Owner

Thank you! You can enhance your search with a filter by providing a query property, as seen here https://github.com/matteodem/meteor-easy-search#createsearchindexname-options.

Will you use elastic search OR mongo-db? With mongo-db it expects a selector object (http://docs.meteor.com/#selectors) and with elastic search a query object (http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-queries.html)

@Sivli-Embir
Copy link
Author

Oh, OH! Yes thats what I wanted. I saw that before but I did not make the link up with EasySearch.changeProperty.

Ok follow up, is there a way to limit the result fields? I only need name and _id from my documents. This could pull down MBs of data if left as is. I am searching over literal documents.

@Sivli-Embir
Copy link
Author

Ach still having a problem with this. Is there any way to access properties set by EasySearch.changeProperty in the permission argument from EasySearch.createSearchIndex? I will also need the userId.

@matteodem
Copy link
Owner

It's actually missing for both of them, but it would be as easy as adding a fields property where you can define those needed (like here http://docs.meteor.com/#find, see "fields"). I'll create an enhancement ticket for it.

Are you changing properties in our permission argument? Can you please create a new github ticket with a code example in there? I'll also be probably adding some new functions for filter / faceting management + a section in the README

matteodem pushed a commit that referenced this issue Dec 18, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants