Best practice for storing my queries


(Tomer Praizler) #1

I have a web application, in which users can define a little complex search queries.
I want to be able to store those queries for them, so those queries will be available any time.

So If a user login to my system , he can get lets say 4 search queries which he can click and run.
Those for queries are unique and should be available only for this user.

What is the best solution here? is there a good way to save those queries?


(ddorian43) #2

What is the problem where ? Just use the whole query (or a hash of it)(make sure the "body" has ordered keys) as a unique-index (or id) and store it in a database/table or elasticsearch/index.
Also store a "user_id", "created_on" on the document/row etc.


(Tomer Praizler) #3

Thanks @ddorian43!

Using a relational database to save this information is definitly an option.
I though maybe elasticsearch has its own way of doing this, like using the precolator for example.

Here is a post talking exactly on this use case.
There is a suggestion to use filter alias. The thing is that question is a little out dated, and I am not sure if it is recommended or not.


(ddorian43) #4

I'm afraid you're overthinking. Just store it in rdbms/es/mongodb/redis/whatever.
Filter aliases looks to not be best for your case.


(system) #5