Jordi
Jordi

Reputation: 23257

ElasticSearch index per user?

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.

Upvotes: 2

Views: 1781

Answers (1)

Frederick Cheung
Frederick Cheung

Reputation: 84142

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.

Upvotes: 2

Related Questions