Catatan
Akses ke halaman ini memerlukan otorisasi. Anda dapat mencoba masuk atau mengubah direktori.
Akses ke halaman ini memerlukan otorisasi. Anda dapat mencoba mengubah direktori.
Catatan
Pencarian Azure AI tersedia melalui portal Azure, REST API, dan Azure SDK. Ini juga mendukung Foundry IQ, lapisan pengetahuan terkelola yang mengubah konten perusahaan menjadi pangkalan pengetahuan yang dapat digunakan kembali dan sadar izin untuk agen di portal Microsoft Foundry.
Saat membuat kueri untuk Pencarian Azure AI, Anda dapat mengganti pengurai kueri simple default dengan pengurai kueri Lucene untuk merumuskan ekspresi kueri khusus dan tingkat lanjut.
Pengurai Lucene mendukung format kueri yang kompleks, seperti kueri dengan ruang lingkup bidang, pencarian fuzzy, pencarian karakter pengganti infiks dan akhiran, pencarian kedekatan, peningkatan bobot istilah, dan pencarian dengan ekspresi reguler. Kekuatan tambahan dilengkapi dengan lebih banyak persyaratan pemrosesan sehingga Anda harus mengharapkan waktu eksekusi yang sedikit lebih lama. Dalam artikel ini, Anda dapat menelusuri contoh yang menunjukkan operasi kueri berdasarkan sintaks penuh.
Catatan
Banyak konstruksi kueri khusus yang dimungkinkan oleh sintaks kueri Lucene lengkap tidak mengalami analisis teks, yang bisa mengejutkan jika Anda mengharapkan stemming atau lemmatisasi. Analisis leksikal hanya dilakukan pada istilah lengkap (kueri istilah atau kueri frasa). Jenis kueri dengan istilah yang tidak lengkap (kueri awalan, kueri wildcard, kueri regex, kueri fuzzy) ditambahkan langsung ke pohon kueri, melewati tahap analisis. Satu-satunya transformasi yang dilakukan pada istilah kueri parsial adalah diubah menjadi huruf kecil.
Indeks sampel hotel
Kueri berikut didasarkan pada indeks sampel hotel, yang dapat Anda buat dengan mengikuti instruksi di Quickstart: Pencarian teks lengkap di Azure portal.
Contoh kueri diartikulasikan menggunakan permintaan REST API dan POST. Anda dapat menempelkan dan menjalankannya di klien REST. Atau, gunakan tampilan JSON Search Explorer di Azure portal. Dalam tampilan JSON, Anda bisa menempelkan contoh kueri yang diperlihatkan di sini dalam artikel ini.
Permintaan header harus memiliki nilai berikut:
| Kunci | Nilai |
|---|---|
| Jenis-Konten | application/json |
| kunci API |
<your-search-service-api-key>, baik kueri atau kunci admin |
Parameter URI harus menyertakan titik akhir search service Anda dengan nama indeks, koleksi dokumen, perintah pencarian, dan versi API, mirip dengan contoh berikut:
https://{{service-name}}.search.windows.net/indexes/hotels-sample/docs/search?api-version=2026-04-01
Isi permintaan harus dibentuk sebagai JSON yang valid:
{
"search": "*",
"queryType": "full",
"select": "HotelId, HotelName, Category, Tags, Description",
"count": true
}
searchdikonfigurasikan sebagai * adalah kueri yang tidak ditentukan, setara dengan pencarian null atau kosong. Ini tidak terlalu berguna, tetapi ini adalah pencarian paling sederhana yang dapat Anda lakukan, dan menunjukkan semua bidang yang dapat diambil dalam indeks, dengan semua nilai.queryTypedisetel ke penuh menggunakan pengurai kueri Lucene secara penuh dan diperlukan untuk sintaks ini.selectdiatur ke daftar bidang yang dibatasi koma digunakan untuk komposisi hasil pencarian, termasuk hanya bidang yang berguna dalam konteks hasil pencarian.countmengembalikan jumlah dokumen yang cocok dengan kriteria pencarian. Pada string pencarian kosong, jumlahnya adalah semua dokumen dalam indeks (50 dalam indeks sampel hotel).
Contoh 1: Pencarian berbidang
Pencarian berbasis bidang membatasi ekspresi pencarian ke bidang tertentu. Contoh ini mencari nama hotel dengan istilah hotel di dalamnya, tetapi bukan motel. Anda dapat menentukan beberapa bidang menggunakan AND.
Saat Anda menggunakan sintaks kueri ini, Anda dapat menghilangkan searchFields parameter saat bidang yang ingin Anda kueri berada dalam ekspresi pencarian itu sendiri. Jika Anda menyertakan searchFields dengan pencarian bidang, fieldName:searchExpression selalu diutamakan daripada searchFields.
POST /indexes/hotel-samples-index/docs/search?api-version=2026-04-01
{
"search": "HotelName:(hotel NOT motel) AND Category:'Boutique'",
"queryType": "full",
"select": "HotelName, Category",
"count": true
}
Respons untuk kueri ini akan terlihat mirip dengan contoh berikut, difilter di Boutique, mengembalikan hotel yang menyertakan hotel dalam nama, sambil mengecualikan hasil yang menyertakan motel dalam nama.
{
"@odata.count": 5,
"value": [
{
"@search.score": 2.2289815,
"HotelName": "Stay-Kay City Hotel",
"Category": "Boutique"
},
{
"@search.score": 1.3862944,
"HotelName": "City Skyline Antiquity Hotel",
"Category": "Boutique"
},
{
"@search.score": 1.355046,
"HotelName": "Old Century Hotel",
"Category": "Boutique"
},
{
"@search.score": 1.355046,
"HotelName": "Sublime Palace Hotel",
"Category": "Boutique"
},
{
"@search.score": 1.355046,
"HotelName": "Red Tide Hotel",
"Category": "Boutique"
}
]
}
Ekspresi pencarian dapat berupa istilah tunggal atau frasa, atau ekspresi yang lebih kompleks dalam tanda kurung, secara opsional dengan operator Boolean. Beberapa contoh meliputi:
HotelName:(hotel NOT motel)Address/StateProvince:("WA" OR "CA")Tags:("free wifi" NOT "free parking") AND "coffee in lobby"
Pastikan untuk menempatkan frasa dalam tanda kutip jika Anda ingin kedua string dievaluasi sebagai entitas tunggal, seperti dalam hal ini mencari dua lokasi yang berbeda di Address/StateProvince bidang . Tergantung pada klien, Anda mungkin perlu menghindari (\) tanda kutip.
Bidang yang ditentukan dalam fieldName:searchExpression harus merupakan bidang yang dapat dicari. Untuk mempelajari bagaimana definisi bidang diatribusikan, lihat Membuat Indeks (REST API).
Contoh 2: Pencarian fuzzy
Pencarian fuzzy mencocokkan istilah yang mirip, termasuk kesalahan ejaan. Untuk melakukan pencarian fuzzy, tambahkan simbol tilde ~ di akhir satu kata dengan parameter opsional yang menentukan jarak edit, dengan nilai antara 0 dan 2. Misalnya, blue~ atau blue~1 akan mengembalikan warna biru, blues, dan lem.
POST /indexes/hotel-samples-index/docs/search?api-version=2026-04-01
{
"search": "Tags:conserge~",
"queryType": "full",
"select": "HotelName, Category, Tags",
"searchFields": "HotelName, Category, Tags",
"count": true
}
Respons untuk kueri ini merujuk pada concierge dalam dokumen yang cocok, dipangkas untuk singkatnya:
{
"@odata.count": 9,
"value": [
{
"@search.score": 1.4947624,
"HotelName": "Twin Vortex Hotel",
"Category": "Luxury",
"Tags": [
"bar",
"restaurant",
"concierge"
]
},
{
"@search.score": 1.1685618,
"HotelName": "Stay-Kay City Hotel",
"Category": "Boutique",
"Tags": [
"view",
"air conditioning",
"concierge"
]
},
{
"@search.score": 1.1465473,
"HotelName": "Old Century Hotel",
"Category": "Boutique",
"Tags": [
"pool",
"free wifi",
"concierge"
]
},
. . .
]
}
Frasa tidak didukung secara langsung tetapi Anda dapat menentukan kecocokan fuzzy pada setiap istilah frasa multi-bagian, seperti search=Tags:landy~ AND sevic~. Ekspresi kueri ini menemukan 15 kecocokan pada layanan binatu.
Catatan
Kueri fuzzy tidak dianalisis. Jenis kueri dengan istilah yang tidak lengkap (kueri awalan, kueri wildcard, kueri regex, kueri fuzzy) ditambahkan langsung ke pohon kueri, melewati tahap analisis. Satu-satunya transformasi yang dilakukan pada istilah kueri parsial adalah mengubah menjadi huruf kecil.
Contoh 3: Pencarian terdekat
Pencarian terdekat menemukan istilah yang saling berdekatan dalam sebuah dokumen. Sisipkan simbol tilde ~ di akhir frasa diikuti dengan jumlah kata yang membuat batas kedekatan.
Kueri ini mencari istilah hotel dan bandara dalam lima kata satu sama lain dalam dokumen. Tanda kutip di-escape (\") untuk mempertahankan frasa:
POST /indexes/hotel-samples-index/docs/search?api-version=2026-04-01
{
"search": "Description: \"hotel airport\"~5",
"queryType": "full",
"select": "HotelName, Description",
"searchFields": "HotelName, Description",
"count": true
}
Respons untuk kueri ini akan terlihat mirip dengan contoh berikut:
{
"@odata.count": 1,
"value": [
{
"@search.score": 0.69167054,
"HotelName": "Trails End Motel",
"Description": "Only 8 miles from Downtown. On-site bar/restaurant, Free hot breakfast buffet, Free wireless internet, All non-smoking hotel. Only 15 miles from airport."
}
]
}
Contoh 4: Penambahan bobot istilah
Peningkatan istilah mengacu pada peringkat dokumen yang lebih tinggi jika berisi istilah yang didorong, relatif terhadap dokumen yang tidak berisi istilah. Untuk meningkatkan istilah, gunakan simbol caret ^ dengan faktor penguatan (angka) di akhir istilah yang Anda cari. Faktor dorongan default adalah 1, dan meskipun harus positif, nilainya bisa kurang dari 1 (misalnya, 0,2). Peningkatan istilah berbeda dari profil penilaian karena profil penilaian memberikan nilai lebih pada bidang tertentu, bukan istilah tertentu.
Dalam kueri before ini, cari beach access dan perhatikan bahwa ada enam dokumen yang cocok pada satu atau kedua istilah.
POST /indexes/hotel-samples-index/docs/search?api-version=2026-04-01
{
"search": "beach access",
"queryType": "full",
"select": "HotelName, Description, Tags",
"searchFields": "HotelName, Description, Tags",
"count": true
}
Bahkan, hanya dua dokumen yang cocok pada access. Instans pertama berada di posisi kedua, meskipun dokumen tidak memiliki istilah pantai.
{
"@odata.count": 6,
"value": [
{
"@search.score": 1.068669,
"HotelName": "Johnson's Family Resort",
"Description": "Family oriented resort located in the heart of the northland. Operated since 1962 by the Smith family, we have grown into one of the largest family resorts in the state. The home of excellent Smallmouth Bass fishing with 10 small cabins, we're a home not only to fishermen but their families as well. Rebuilt in the early 2000's, all of our cabins have all the comforts of home. Sporting a huge **beach** with multiple water toys for those sunny summer days and a Lodge full of games for when you just can't swim anymore, there's always something for the family to do. A full marina offers watercraft rentals, boat launch, powered dock slips, canoes (free to use), & fish cleaning facility. Rent pontoons, 14' fishing boats, 16' fishing rigs or jet ski's for a fun day or week on the water. Pets are accepted in the lakeside cottages.",
"Tags": [
"24-hour front desk service",
"pool",
"coffee in lobby"
]
},
{
"@search.score": 1.0162708,
"HotelName": "Campus Commander Hotel",
"Description": "Easy **access** to campus and steps away from the best shopping corridor in the city. From meetings in town or gameday, enjoy our prime location between the union and proximity to the university stadium.",
"Tags": [
"free parking",
"coffee in lobby",
"24-hour front desk service"
]
},
{
"@search.score": 0.9050383,
"HotelName": "Lakeside B & B",
"Description": "Nature is Home on the **beach**. Explore the shore by day, and then come home to our shared living space to relax around a stone fireplace, sip something warm, and explore the library by night. Save up to 30 percent. Valid Now through the end of the year. Restrictions and blackouts may apply.",
"Tags": [
"laundry service",
"concierge",
"free parking"
]
},
{
"@search.score": 0.8955848,
"HotelName": "Windy Ocean Motel",
"Description": "Oceanfront hotel overlooking the **beach** features rooms with a private balcony and 2 indoor and outdoor pools. Inspired by the natural beauty of the island, each room includes an original painting of local scenes by the owner. Rooms include a mini fridge, Keurig coffee maker, and flatscreen TV. Various shops and art entertainment are on the boardwalk, just steps away.",
"Tags": [
"pool",
"air conditioning",
"bar"
]
},
{
"@search.score": 0.83636594,
"HotelName": "Happy Lake Resort & Restaurant",
"Description": "The largest year-round resort in the area offering more of everything for your vacation - at the best value! What can you enjoy while at the resort, aside from the mile-long sandy **beaches** of the lake? Check out our activities sure to excite both young and young-at-heart guests. We have it all, including being named "Property of the Year" and a "Top Ten Resort" by top publications.",
"Tags": [
"pool",
"bar",
"restaurant"
]
},
{
"@search.score": 0.7808502,
"HotelName": "Swirling Currents Hotel",
"Description": "Spacious rooms, glamorous suites and residences, rooftop pool, walking **access** to shopping, dining, entertainment and the city center. Each room comes equipped with a microwave, a coffee maker and a minifridge. In-room entertainment includes complimentary W-Fi and flat-screen TVs. ",
"Tags": [
"air conditioning",
"laundry service",
"24-hour front desk service"
]
}
]
}
Dalam kueri setelah, ulangi pencarian, kali ini memprioritaskan hasil dengan istilah pantai dibandingkan dengan istilah akses. Versi yang dapat dibaca oleh manusia dari kueri adalah search=Description:beach^2 access. Tergantung pada klien Anda, Anda mungkin harus mengekspresikan ^2 sebagai %5E2.
POST /indexes/hotel-samples-index/docs/search?api-version=2026-04-01
{
"search": "Description:beach^2 access",
"queryType": "full",
"select": "HotelName, Description, Tags",
"searchFields": "HotelName, Description, Tags",
"count": true
}
Setelah Anda meningkatkan istilah pantai, pertandingan di Campus Commander Hotel bergerak turun ke posisi kelima.
{
"@odata.count": 6,
"value": [
{
"@search.score": 2.137338,
"HotelName": "Johnson's Family Resort",
"Description": "Family oriented resort located in the heart of the northland. Operated since 1962 by the Smith family, we have grown into one of the largest family resorts in the state. The home of excellent Smallmouth Bass fishing with 10 small cabins, we're a home not only to fishermen but their families as well. Rebuilt in the early 2000's, all of our cabins have all the comforts of home. Sporting a huge beach with multiple water toys for those sunny summer days and a Lodge full of games for when you just can't swim anymore, there's always something for the family to do. A full marina offers watercraft rentals, boat launch, powered dock slips, canoes (free to use), & fish cleaning facility. Rent pontoons, 14' fishing boats, 16' fishing rigs or jet ski's for a fun day or week on the water. Pets are accepted in the lakeside cottages.",
"Tags": [
"24-hour front desk service",
"pool",
"coffee in lobby"
]
},
{
"@search.score": 1.8100766,
"HotelName": "Lakeside B & B",
"Description": "Nature is Home on the beach. Explore the shore by day, and then come home to our shared living space to relax around a stone fireplace, sip something warm, and explore the library by night. Save up to 30 percent. Valid Now through the end of the year. Restrictions and blackouts may apply.",
"Tags": [
"laundry service",
"concierge",
"free parking"
]
},
{
"@search.score": 1.7911696,
"HotelName": "Windy Ocean Motel",
"Description": "Oceanfront hotel overlooking the beach features rooms with a private balcony and 2 indoor and outdoor pools. Inspired by the natural beauty of the island, each room includes an original painting of local scenes by the owner. Rooms include a mini fridge, Keurig coffee maker, and flatscreen TV. Various shops and art entertainment are on the boardwalk, just steps away.",
"Tags": [
"pool",
"air conditioning",
"bar"
]
},
{
"@search.score": 1.6727319,
"HotelName": "Happy Lake Resort & Restaurant",
"Description": "The largest year-round resort in the area offering more of everything for your vacation - at the best value! What can you enjoy while at the resort, aside from the mile-long sandy beaches of the lake? Check out our activities sure to excite both young and young-at-heart guests. We have it all, including being named "Property of the Year" and a "Top Ten Resort" by top publications.",
"Tags": [
"pool",
"bar",
"restaurant"
]
},
{
"@search.score": 1.0162708,
"HotelName": "Campus Commander Hotel",
"Description": "Easy access to campus and steps away from the best shopping corridor in the city. From meetings in town or gameday, enjoy our prime location between the union and proximity to the university stadium.",
"Tags": [
"free parking",
"coffee in lobby",
"24-hour front desk service"
]
},
{
"@search.score": 0.7808502,
"HotelName": "Swirling Currents Hotel",
"Description": "Spacious rooms, glamorous suites and residences, rooftop pool, walking access to shopping, dining, entertainment and the city center. Each room comes equipped with a microwave, a coffee maker and a minifridge. In-room entertainment includes complimentary W-Fi and flat-screen TVs. ",
"Tags": [
"air conditioning",
"laundry service",
"24-hour front desk service"
]
}
]
}
Contoh 5: Regex
Pencarian ekspresi reguler menemukan kecocokan berdasarkan konten antara garis miring ke depan / dan string huruf kecil, seperti yang didokumentasikan dalam kelas RegExp.
POST /indexes/hotel-samples-index/docs/search?api-version=2026-04-01
{
"search": "HotelName:/(Mo|Ho)tel/",
"queryType": "full",
"select": "HotelName",
"count": true
}
Tanggapan untuk kueri ini akan terlihat mirip dengan contoh berikut (dipangkas untuk singkat):
{
"@odata.count": 25,
"value": [
{
"@search.score": 1,
"HotelName": "Country Residence Hotel"
},
{
"@search.score": 1,
"HotelName": "Downtown Mix Hotel"
},
{
"@search.score": 1,
"HotelName": "Gastronomic Landscape Hotel"
},
. . .
{
"@search.score": 1,
"HotelName": "Trails End Motel"
},
{
"@search.score": 1,
"HotelName": "Nordick's Valley Motel"
},
{
"@search.score": 1,
"HotelName": "King's Cellar Hotel"
}
]
}
Catatan
Kueri regex tidak dianalisis. Satu-satunya transformasi yang dilakukan pada istilah kueri parsial adalah mengubah menjadi huruf kecil.
Contoh 6: Pencarian wildcard
Anda dapat menggunakan sintaksis yang dikenali secara umum untuk pencarian dengan beberapa (*) atau satu (?) karakter pengganti. Pengurai kueri Lucene mendukung penggunaan simbol-simbol ini dengan satu istilah, dan bukan frasa.
Dalam kueri ini, cari nama hotel yang berisi awalan sc. Anda tidak dapat menggunakan * simbol atau ? sebagai karakter pertama pencarian.
POST /indexes/hotel-samples-index/docs/search?api-version=2026-04-01
{
"search": "HotelName:sc*",
"queryType": "full",
"select": "HotelName",
"count": true
}
Respons untuk kueri ini akan terlihat mirip dengan contoh berikut:
{
"@odata.count": 1,
"value": [
{
"@search.score": 1,
"HotelName": "Waterfront Scottish Inn"
}
]
}
Catatan
Kueri wildcard tidak dianalisis. Satu-satunya transformasi yang dilakukan pada istilah kueri parsial adalah mengubah menjadi huruf kecil.
Konten terkait
- Mulai cepat: Pencarian teks lengkap
- Pencarian teks lengkap di Pencarian Azure AI
- Sintaks kueri sederhana di Pencarian Azure AI
- sintaks kueri Lucene dalam Pencarian Azure AI
- $c0$sintaks OData $filter dalam Pencarian Azure AI