When I index something in Elasticsearch, why doesn't it show in my search straight after?

1 min read

I got burnt by this little architectural nuance in Elasticsearch recently. While batch processing items in a content store, updating their status, then searching for more items, I kept getting stale data and didn’t understand why. It turned out that Elasticsearch is _near_ realtime, with a default 1s refresh interval. So if you index and query within a second, you’re going to see old data. The best way around this is to do a refresh on the index just before you access it to make sure you have the latest data.

Need a CTO in the room?

Tell me what is going on. The first conversation is free, and I will say honestly whether I can help. If I can’t, I’ll introduce you to someone who can.

Cape Town, working remotely. My mornings overlap with Australian afternoons, and my afternoons with the UK, Europe and the US east coast. Or message me on LinkedIn.