I have an index with many documents. In my app, a login happens under a username. For a user only a group of data should be visible, that is I want to restrict each user to a set of documents. Can somebody offer a solution of how to implement this using elasticsearch?.
Suppose my index contain the follwing documents
record1
record2
record3
record4
And I have say 2 users, user1 and user2
When the user1 is logged in, he should have access to "record1","record2" and "record3". Where for user2 , the access should only be to "record4".
Probably you can add one more column to the index where in you can persist the intended user for the record and while querying the index you can check if the logged in user in among the users specified in the column.
I would advise you to use a index aliases.
Index aliases has the capability to add filter to them.
So create 2 aliases , one for each user.
Now for each alias , create a filter which restricts the user to his own set of documents. ( Just use a document ID search )
Restrict these users to use only these aliases using a proxy.
That should do the trick
Related
I have a rails app and per user create indexes, each index contains documents and each document contains a user profile, profile_id is unique per user, In my case user could update his profile and in my system, I created indexes assume today user-created profile with the first name "rose" and next day decide to update his profile and last name to his profile I need to return both documents when user search, In another word I need if the user wants to search first name elastic return all documents that contain user profiles.
Does anyone know what is query in elastic search?
I need to make a system using ElasticSearch.
Each user has its documents, and the scope of these documents is only inside its user scope. Any user document is no accessible for any other system user.
The question is, what's the best approach, create an index per user, or create a single index containing all the documents of each user.
Each user might have its custom meta-information field over their documents that other users have not.
I know that in general it's proposed to use a single index with user aliases, however I don't understand how to add this custom user's document meta-information in this big index.
For example, imagine userA has two documents indexed, and userB has 3 documents. In my system exists system pre-defined meta-information as filename and description, however, the system allows to each user defines each own custom meta-information, for example: userA might have a meta-information color over its documents, and userB might have a size meta-information field over each document.
I understand one posibility would be add new field on the single index, however, it can be out of bounds.
What's would be the best approach?
Thanks for all.
One index per user sounds like you'd run into trouble at some point - there is an overhead per index that would become significant once you have a lot of users (say 10000 or so)
I don't think you need this though - you could allow custom attributes on a per user basis by using nested fields - each nested object would have name and value properties (possibly multiple value properties) and so you can have arbitrary searchable metadata for your documents without needing to change the mapping each time.
What is the correct way to relate users in parse to one another as friends?
I also want users to be able to query other users but not see all fields, like emails. Is there a way I can create a view on the users table with cloud code, and only return this to the client code?
I was thinking I can create a friends table that will have two columns with 2 pointers, 1 for each user.
thanks for any advice.
I was thinking I can create a friends table that will have two columns with 2 pointers, 1 for each user.
I'll do that too, with a status column to handle pending, blocked...etc
I also want users to be able to query other users but not see all fields, like emails.
You have to add a privateData column on user with ACL restricted to owner only, which would contain private infos such as emails...etc
I have four sub-organizations defined. (/AdminOrg, /subOrgA, /SubOrgB, /subOrgA/SubOrgAA)
my directory.orgunits.list query return below data. I store the return array in a variable called orgUnits[]:
http://pastebin.com/Kzud6SAq
I have 4 users in my organization. one in each sub-organization. the users.list return below data:
http://pastebin.com/6ttSgDSe
I am trying to get no. of users within an organization (without including sub organizations in them)
Option 1:
The query directory.users.list.query("orgUnitPath=/subOrgA") includes users from sub organization (/subOrgA/SubOrgAA) too and does not meet my needs.
Option 2:
I tried the query directory.users.list.query("orgName=orgUnits[]->name"). It queries for users[]->organizations[]->name. And this field is null by default. It does not get populated with orgUnits[]->name.
My questions are
How to populate users.organizations[].name?
Is there any way I can get users within an organization without including sub-organizations in them
Unfortunately it isn't possible to search for users within an orgUnit not including sub-orgs. The orginations field in the Users resource, as well as the orgName, orgTitle, orgDepartment, orgDescription,
orgCostCenter query parameters, refer to a completely separate set of data that appears to be used by the API only. Only the orgUnitPath field and query parameter operate on the organizations visible within the Google Apps Admin Console.
Just wondering if what I want to do is possible with Solr:
I have a Solr index of 'Users' [id, name, join_date] and on my site and I have a page /users which has a Solr query that lists all of the users in the index in alphabetical order.
On my site users can 'follow' other users. I have added another page /followers which first gets all the user_ids which are 'following' the logged in user from MySQL - then uses these IDs to query Solr to only return users which the current user is following.
This all works fine.
But the problem is, I'd like to be able to order the users returned on /followers in order of when they first started following the logged in user - I keep this information in a join table in MySQL. But my Solr documents don't contain this date - as obviously one user can have many followers and vise versa. Also I can't just use MySQL to server this page as I need to keep it Solr query-able.
Would love some insight into this - it's been bugging me for a while now.
you can do that with ExternalField but you need to export your info from the db to a text file (and keep it updated etc).
This guy here discusses a way to do it without ExternalField, but requires customizing Sorl code.