Full-text search finds relevant documents from unstructured text rather than requiring an exact field value. A search for “vaccine” can return material about vaccination, inoculations, and jabs. Results receive positive relevance scores, with higher-scored documents normally appearing first. section 1.2.1 section 8.1
Use it for text such as blog posts, research articles, emails, PDFs, reviews, or a bookstore catalog. Unlike structured searches on dates, numbers, or exact terms, a full-text query looks for close textual matches and ranks them instead of returning a simple yes-or-no result. section 1.2.1 section 8.1
Elasticsearch makes text searchable by analyzing it into tokens and building an inverted index that maps tokens to documents. At query time, a full-text field is analyzed again with its associated analyzer, then its tokens are matched against that index. Using the same analyzer at indexing and search time keeps indexed words and query words comparable. section 1.3.1 section 3.1.3
Choose a query form based on the search behavior needed:
- Use match for the common case of searching text fields and scoring documents by relevance. section 10.13
- Use match_phrase or match_phrase_prefix when words must occur in a defined order; use phrase_slop when words may be missing between phrase terms. section 10.13
- Use multi_match to search a user’s criteria across multiple fields. section 10.13
- Use query_string for AND, OR, and NOT syntax, or simple_query_string when malformed user syntax should be suppressed rather than raise an exception. section 10.13
Bookstore search: disambiguating Java
A bookstore search for “Java” should favor technical programming books, not documents about the Indonesian island or its coffee. This is the central goal of full-text search: return results that best fit the user’s intended meaning and place them ahead of weaker matches. Index a catalog such as the 50-book books dataset, then issue searches through the _search API using Query DSL; match queries are the usual starting point. section 10.0 section 10.2 section 8.9
Relevance is useful but not perfect. Precision and recall influence which documents are returned, so some results may be irrelevant. Improve search behavior with text analysis such as synonyms, stemming, and stop words, and use supporting features such as highlighting, pagination, scoring explanations, or result manipulation when needed. section 8.1 section 1.3.1 section 8.9
Full-text search suits high-read, large-text search workloads and can scale horizontally. Prototype requirements before choosing Elasticsearch: it is not designed for complex relational joins, immediate-consistency transactions, or workloads optimized primarily for high-volume writes. section 1.3.1 section 1.4.4 section 1.2.2
Compare the traditional database-backed search layout when evaluating whether database full-text support is sufficient or a distributed search engine is warranted. section 1.2.2
