Terim ve Eşleşme Sorguları
Kesin değer eşleştirme için `term` sorgularını, tam metin analizi ve uygunluk puanlaması için `match` sorgularını kullanmayı öğrenin.
Terim ve Eşleşme Sorguları, CoddyKit'te ücretsiz bir Elasticsearch & Full Text Search Systems dersidir. Bu, 4 dersinin 2. dersidir. Aşağıdan dersin tamamını ücretsiz okuyabilir, sonra tarayıcıda yerleşik kod editörü ve 7/24 yapay zeka koçu ile uygulamalı olarak pratik yapabilirsin. Bu, Elasticsearch & Full Text Search Systems öğrenme yolunun bir parçasıdır ve ilerlemeniz web ve CoddyKit uygulaması arasında senkronize olur. Elasticsearch & Full Text Search Systems kursu toplamda 4 dersten oluşur.
Bu dersin bazı bölümleri henüz çevrilmemiş olup İngilizce olarak gösterilmektedir.
Intro to Term & Match Queries
Welcome to the fundamentals of querying data in Elasticsearch! Today, we'll explore two essential query types: term and match.
Understanding their differences is crucial for effective search. We'll learn when to use each to get exactly the results you need, whether it's an exact value or a flexible full-text search.
Indexing Sample Documents
Before we query, let's index some simple documents into an index called products. We'll use these examples throughout the lesson.
Run these curl commands in your terminal (assuming Elasticsearch is running on localhost:9200):
curl -X PUT "localhost:9200/products/_doc/1?pretty" -H 'Content-Type: application/json' -d'
{
"name": "Laptop Pro X1",
"category": "Electronics",
"description": "A powerful and lightweight laptop for professionals.",
"price": 1200
}'
curl -X PUT "localhost:9200/products/_doc/2?pretty" -H 'Content-Type: application/json' -d'
{
"name": "Wireless Mouse",
"category": "Accessories",
"description": "Ergonomic wireless mouse with long battery life.",
"price": 25
}'
curl -X PUT "localhost:9200/products/_doc/3?pretty" -H 'Content-Type: application/json' -d'
{
"name": "Gaming Keyboard",
"category": "Electronics",
"description": "Mechanical keyboard for intense gaming sessions.",
"price": 90
}'`term` Query: Exact Matching
The term query is used for finding exact values in a field. It looks for a precise match without any text analysis (like lowercasing or stemming).
- It's ideal for structured data like product IDs, categories, tags, or status fields.
- It works best with fields that are mapped as
keyword(non-analyzed strings) or numeric types.
`term` Query in Action
Let's find all products with the exact category "Electronics". Notice we're querying category.keyword because the default text field would be analyzed.
Try this curl command:
curl -X GET "localhost:9200/products/_search?pretty" -H 'Content-Type: application/json' -d'
{
"query": {
"term": {
"category.keyword": "Electronics"
}
}
}'Understanding .keyword
When you index a string field (like category), Elasticsearch often creates two versions by default:
category: Atextfield, which is analyzed (broken into words, lowercased).category.keyword: Akeywordfield, which is treated as a single, exact string.
The term query expects an exact match, so using the .keyword sub-field ensures your query string isn't analyzed and matches the exact stored value.
`match` Query: Full-Text Power
The match query is your go-to for full-text search. Unlike term, it's designed to be smart about text.
- It performs text analysis on your search query.
- It breaks your query string into individual terms, lowercases them, and sometimes stems them (e.g., "running" -> "run").
- It then finds documents that contain these analyzed terms, and also assigns a relevancy score.
`match` Query in Action
Let's search for products with "powerful laptop" in their description. Even if the document contains "A powerful and lightweight laptop", the match query will find it.
Try this curl command:
curl -X GET "localhost:9200/products/_search?pretty" -H 'Content-Type: application/json' -d'
{
"query": {
"match": {
"description": "powerful laptop"
}
}
}'The Magic of Text Analysis
When you use a match query, Elasticsearch's text analysis process kicks in:
- Tokenization: "powerful laptop" becomes "powerful" and "laptop".
- Lowercasing: "Powerful" becomes "powerful".
- Stop Words: Common words like "a", "the" might be removed (depending on the analyzer).
This makes match queries highly flexible for natural language search, finding relevant results even with minor variations in phrasing or case.
`term` vs `match`: Key Differences
Here's a quick summary of when to use each query type:
termquery:
- For exact value matching.
- Does NOT perform text analysis on query string.
- Best forkeywordfields, IDs, precise filters.matchquery:
- For full-text search.
- PERFORMS text analysis on query string.
- Best fortextfields, search bars, descriptive content.
Query Understanding Check
Which of the following statements are true regarding term and match queries in Elasticsearch?
Recap: `term` & `match`
Great job! You've learned the fundamental difference between term and match queries.
termis for surgical, exact value searches.matchis for flexible, full-text searches leveraging powerful text analysis.
Knowing when to use each is key to building effective search experiences. Next, we'll explore how to combine these and other queries to create even more sophisticated search logic!
Yapay zeka eğitmeniyle Elasticsearch & Full Text Search Systems öğren — ücretsiz
Tarayıcında gerçek kod yaz ve çalıştır, 7/24 yapay zeka eğitmeninden anında yardım al; web'de ya da uygulamada kaldığın yerden devam et.
- Kurslar
- 12
- Dersler
- 48
Sıkça Sorulan Sorular
“Terim ve Eşleşme Sorguları” dersi ücretsiz mi?
Evet — “Terim ve Eşleşme Sorguları” dersin tüm metni burada web'de ücretsiz olarak okunabilir. Etkileşimli olarak pratik yapmak (yerleşik kod editörü ve 7/24 yapay zeka koçu) ve Elasticsearch & Full Text Search Systems kursunun geri kalanını açmak için CoddyKit PRO'ya yükselt. Elasticsearch & Full Text Search Systems kursu toplamda 4 dersten oluşur.
“Terim ve Eşleşme Sorguları” dersinde ne öğreneceğim?
Kesin değer eşleştirme için `term` sorgularını, tam metin analizi ve uygunluk puanlaması için `match` sorgularını kullanmayı öğrenin. Elasticsearch & Full Text Search Systems ile uygulamalı kodu tarayıcıda doğrudan çalıştırarak pratik yaparsın ve 7/24 yapay zeka koçu dersi çalışırken sorularını yanıtlar.
Elasticsearch & Full Text Search Systems öğrenmeye başlamak için deneyim gerekli mi?
Önceden deneyim gerekmez. CoddyKit'te Elasticsearch & Full Text Search Systems, başlangıçtan ileri seviyeye kadar yapılandırıldığı için buradan başlayabilir veya başından başlayıp kendi hızında ilerleme yapabilirsin. Bu, 4 dersinin 2. dersidir.
“Terim ve Eşleşme Sorguları” dersi ne kadar sürer?
Çoğu CoddyKit dersi yaklaşık 5–10 dakika sürer. Her biri kısa ve etkileşimli olduğu için sabit ilerleme yaparsın ve web ile uygulama arasında tam olarak bıraktığın yerden devam edebilirsin.
Bu Elasticsearch & Full Text Search Systems dersinde kod yazıp çalıştırabilir miyim?
Evet. Her Elasticsearch & Full Text Search Systems dersi yerleşik bir kod editörü içerir, bu sayede tarayıcıda gerçek kod yazıp çalıştırabilir ve anlık yapay zeka geri bildirimi alırsın — yerel kurulum gerekli değildir.
Bu kursun tüm dersleri
- Sorgu DSL'sine Giriş
- Terim ve Eşleşme Sorguları
- Bool ile Sorguları Birleştirme
- Filtreleme, Aralıklar ve Sorgu Bağlamı