How to implement a user specific search?


(pmeier) #1

Hi all,

I have a bunch of items to search. Normally I would put them in one index
and they are searchable. But I have the restriction that every user should
only see a specific subset of all the items.

The problem is I don't know how to implement this performantly. One option
would be to include the user-ids who are allowed to search or see the item
as a field. The second one would be to create a own index for every user -
but here's the question how the performance is if there are 5000+ users or
maybe even more.

Is there another elegant solution to this problem I haven't found out yet?
Searching didn't return anything useful to me.

Thanks for every reply and indea.

Patrick Meier.


(Clinton Gormley) #2

Hi Patrick

I have a bunch of items to search. Normally I would put them in one
index and they are searchable. But I have the restriction that every
user should only see a specific subset of all the items.

You can use alias filters:

  • You have one index which contains data for all your users.
  • You have one alias for each user, which specifies the filter
    to be applied for that alias (eg { term => { user_id => 123}}
  • Your users query your index via their alias.

http://www.elasticsearch.org/guide/reference/api/admin-indices-aliases.html

clint


(David Pilato) #3

That's really a cool feature that I was not aware about.

Thanks for the question and the answer.

David :wink:

Le 11 oct. 2011 à 16:42, Clinton Gormley clint@traveljury.com a écrit :

Hi Patrick

I have a bunch of items to search. Normally I would put them in one
index and they are searchable. But I have the restriction that every
user should only see a specific subset of all the items.

You can use alias filters:

  • You have one index which contains data for all your users.
  • You have one alias for each user, which specifies the filter
    to be applied for that alias (eg { term => { user_id => 123}}
  • Your users query your index via their alias.

http://www.elasticsearch.org/guide/reference/api/admin-indices-aliases.html

clint


(pmeier) #4

Hi Clinton,

thanks a lot for your quick reply. This was the elegant solution I was
searching for.

Patrick Meier

On 11 Okt., 16:42, Clinton Gormley cl...@traveljury.com wrote:

Hi Patrick

I have a bunch of items to search. Normally I would put them in one
index and they are searchable. But I have the restriction that every
user should only see a specific subset of all the items.

You can use alias filters:

  • You have one index which contains data for all your users.
  • You have one alias for each user, which specifies the filter
    to be applied for that alias (eg { term => { user_id => 123}}
  • Your users query your index via their alias.

http://www.elasticsearch.org/guide/reference/api/admin-indices-aliase...

clint


(system) #5