1

I am looking into replacing memcached with elasticsearch. Basically, I need to reduce my software stack and since I will be using elastic for searching, I was thinking of creating an index that will act as a general cache, where I will be storing various items.

Is there a way to create such a "generic bucket" that can hold different items without elastic complaining? From what I have seen so far, when you store an item the 1st time, elastic automatically creates a type for each key. This can lead to trouble if you try to save a different item which happens to have a key elastic already mapped, with a different value.

Any way of accomplishing the above?

Regards

  • Not exactly an answer to your question, but if you want to reduce your stack and your stack includes MySQL, why not use the memcached layer that comes with MySQL? – adamo Dec 28 '14 at 10:09
  • 2
    Elasticsearch and memcached are completely different tools for different purposes. To replace one with the other makes no sense. – Michael Hampton Dec 28 '14 at 15:17
  • 1
    "I need to reduce my software stack". Why "need"? Box got too much stuff on it? Installation instructions too complicated? Cognitive overload? Something else? – Roger Lipscombe Dec 28 '14 at 15:59
5

Elasticsearch is a search and index kind of database, build and optimized for searching and analytics, not for caching.

For a caching server you would use Memcached. But these days there are other alternatives such as Redis (Key-Value database) which is much faster and supports more complex solutions. Carl Zulauf did a great job describing the differences between Redis and Memcached already here on stackoverflow.

  • Hi. Maybe it is not what elastic was built for, but why not, if what I describe can be done. Additionally, why redis instead of memcached? – Thomas Dec 28 '14 at 9:55
  • True, but I like to use the right tool for the right job. About Redis; there's a post on stackoverflow which answers that question. If you still want to do it, I'm sorry but then i can't help. – radriaanse Dec 28 '14 at 10:04
0

While remyseroos answer is absolutely correct I think there are use cases where ElasticSearch (es) could be a great replacement for some functions offered by caching servers.

E.g. imagine using es as the read access layer for a web application with focus on CRUD (and search). Es provides a fast REST API to the data persisted in the data base which you only expose to read data - using es as a cache to the data base. You'd take load of the database, get incredible fast access via an elegant json REST API that you don't have to build yourself.

Some things to consider here are:

  • Only update your es index when needed as updates are slow and
  • use es bulk api where ever possible e.g. when
  • you have to rebuild your index on deployment when
  • you use the memory based index to speed up response times.
  • Security is something to consider up front as securing the es REST interface is somewhat tricky.

In fact we've just built such an application using the elasticsearch-transport-wares and so far it's working great for us.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.