Configuring Elasticsearch for Search in Mobile Apps
Imagine an online store with 10,000 products. A user types "Adidas sneakers" — the app freezes for 5 seconds and then shows an empty list because of a slow LIKE query. Conversion drops. We see this on every other project. Our team with 5 years of experience in Elasticsearch and over 30 completed projects sets up search turnkey: from data indexing to a ready UI with autocomplete and facets. We guarantee response time <200ms even on a million documents.
Why Elasticsearch Instead of LIKE Search?
LIKE in SQLite (or similar databases) cannot rank results, does not support morphology, and slows down on datasets over a thousand records. Elasticsearch provides full-text search, autocomplete, faceted filters, and relevance based on dozens of factors. Speed difference — up to 50× faster for complex queries, which is critical for e-commerce conversion. For example, a search for "sneakers" will find both "sneaker" and "sneakers" in milliseconds.
Architecture: The Mobile App Does Not Call ES Directly
The mobile client sends a request to the backend: GET /api/search?q=sneakers&category=sport. The backend (Laravel/Node) performs the search in Elasticsearch and returns a paginated response. Reasons:
- Security: index structure and credentials are hidden from the client.
- Caching: the server caches popular queries, reducing load on ES.
- Load control: a thousand simultaneous clients do not overload the cluster.
| Criteria | LIKE | Elasticsearch |
|---|---|---|
| Query time (1M rows) | > 5 s | < 200 ms |
| Morphology | no | full |
| Ranking | no | by relevance |
Configuring the Index
For Russian text, a morphological analyzer is mandatory. We use the built-in russian or the analysis-morphology plugin. Without it, the query "sneakers" won't find "sneaker". Example mapping:
{ "mappings": { "properties": { "name": { "type": "text", "analyzer": "russian", "fields": { "keyword": { "type": "keyword" } } } } } } The keyword field is needed for sorting and aggregations — text is not suitable for that.
| Analyzer | Morphology | Performance | License |
|---|---|---|---|
| russian | + | high | built-in |
| analysis-morphology | ++ | medium | plugin |
Elasticsearch is an industry standard; for Russian content, russian is preferred.
How to Implement Autocomplete and Pagination?
Autocomplete (search-as-you-type) is implemented using a field of type search_as_you_type or the completion suggester. The client sends a request on each keystroke with a 300ms debounce, the server returns up to 7 suggestions. For pagination, we use search_after instead of the standard from/size, which is limited to 10,000 results. This enables infinite scroll without a "next page" button.
How We Configure Search for Clients?
Our process includes five stages:
- Data analysis: study product structure, determine fields for indexing, normalize attributes.
- Index design: choose analyzers, set up mapping and auto-updates via Logstash or Kafka.
- API implementation: create an endpoint with pagination (
search_after), facets, and autocomplete. Document in Swagger. - Mobile app integration: connect the API, build UI (skeleton, debounce, infinite scroll). Native SDKs (Alamofire, Retrofit) handle requests.
- Testing and monitoring: check speed (<500ms), enable slowlog, set up alerts in Kibana.
Let's break down a typical case. Client — a marketplace with 50,000 products. Elasticsearch cluster of 3 nodes, indexing via Kafka. After integration, average response time dropped from 3s to 150ms, cart abandonment decreased by 30%. This required configuring the russian analyzer with a custom stop word list and adding boosting by product rating.
What's Included in the Work?
- Documentation on search architecture and query schemas.
- Access to the Elasticsearch server and configured monitoring (Kibana, Grafana).
- Backend controller source code with sample requests (REST, GraphQL).
- Team training: how to update the index, add fields, change relevance.
- One month of support after launch.
Monitoring and Performance
Slow queries (>500ms) are logged via the Elasticsearch slowlog. On the mobile app, we show skeleton placeholders; on a >3s delay — a message "Search taking longer than usual". Baseline metrics: average response time <200ms, error rate <0.5%.
Timelines and Cost
Basic integration (index + API + search UI) takes 1–2 weeks. Full package (facets, autocomplete, offline cache) — 3–4 weeks. Cost is calculated individually after assessing data volume and complexity.
We are ready to take on your project. Contact us — we will prepare an architectural solution and an accurate estimate. Get a consultation by leaving your request.







