CodexBloom - Programming Q&A Platform

Elasticsearch 8.5 Performance Issues with Large Nested Documents During Search Queries

👀 Views: 49 💬 Answers: 1 📅 Created: 2025-08-07
elasticsearch performance nested-documents json

I'm experiencing significant performance degradation when executing search queries on large nested documents in Elasticsearch 8.5. I have an index with documents that can contain up to 1000 nested objects, and when I try to execute a query that filters on a field within those nested objects, the response times can exceed 5 seconds. I've tried using the `nested` query to scope my searches, but it doesn't seem to improve performance as expected. Here’s an example of the query I’m using: ```json { "query": { "nested": { "path": "items", "query": { "bool": { "must": [ { "match": { "items.category": "electronics" } }, { "range": { "items.price": { "lt": 1000 } } } ] } } } } } ``` When I run this query, I notice that the slowest part appears to be the filtering on the nested `items` array. I’ve also experimented with using `inner_hits` to retrieve only relevant nested documents, but that didn't help the query speed either. Additionally, I’ve tried increasing the `refresh_interval` to reduce the load during heavy read operations. Here’s how I updated the settings: ```json PUT /my_index/_settings { "index": { "refresh_interval": "30s" } } ``` Still, the performance remains an issue. I also checked the index mappings and ensured that the fields are properly indexed. My cluster has enough resources (15GB RAM, 4 nodes, SSD storage), so I'm not sure why the search is so slow. I’d appreciate any advice on optimizing these queries or any other approaches to handle large nested documents more efficiently.