Tam Lucene arama söz dizimi örnekleri (gelişmiş sorgular)

Not

Azure Yapay Zeka Arama Azure portalı, REST API'leri ve Azure SDK’ları aracılığıyla kullanılabilir. Ayrıca kuruluş içeriğini Microsoft Foundry portalındaki aracılar için yeniden kullanılabilir, izin kullanan bilgi bankalarına dönüştüren yönetilen bilgi katmanı Foundry IQ'yu temel alır.

Azure Yapay Zeka Arama için sorgu oluştururken, özelleştirilmiş ve gelişmiş sorgu ifadelerini formüle etmek için varsayılan simple sorgu ayrıştırıcısını daha güçlü Lucene sorgu ayrıştırıcısı değiştirebilirsiniz.

Lucene ayrıştırıcısı, alan kapsamlı sorgular, bulanık arama, ara ek ve son ek joker karakter araması, yakınlık araması, terim güçlendirme ve düzenli ifade araması gibi karmaşık sorgu biçimlerini destekler. Ek güç, daha fazla işlem gereksinimiyle birlikte gelir, bu nedenle biraz daha uzun bir yürütme süresi beklemeniz gerekir. Bu makalede, tam söz dizimine göre sorgu işlemlerini gösteren örneklerde adım adım ilerleyebilirsiniz.

Not

Tam Lucene sorgu söz dizimi aracılığıyla mümkün kılınan özel sorgu yapılarının çoğuna metin analizi uygulanmaz; bu durum, kök bulma veya lemmalaştırma bekliyorsanız şaşırtıcı olabilir. Sözcük temelli analiz yalnızca tam terimler (terim sorgusu veya tümcecik sorgusu) üzerinde gerçekleştirilir. Tamamlanmamış terimlere sahip sorgu türleri (ön ek sorgusu, joker sorgu, regex sorgusu, belirsiz sorgu) doğrudan sorgu ağacına eklenir ve analiz aşaması atlanır. Kısmi sorgu terimlerinde gerçekleştirilen tek dönüştürme küçük harfe çevirmedir.

Oteller örnek dizini

Aşağıdaki sorgular, Quickstart: Azure portal'da Tam Metin Araması içindeki yönergeleri izleyerek oluşturabileceğiniz hotels-sample dizinine dayanmaktadır.

Örnek sorgular REST API ve POST istekleri kullanılarak ifade edilir. Bunları bir REST istemcisinde yapıştırabilir ve çalıştırabilirsiniz. Azure portal Search Explorer JSON görünümünü de kullanabilirsiniz. JSON görünümünde, bu makalede gösterilen sorgu örneklerini yapıştırabilirsiniz.

İstek üst bilgileri aşağıdaki değerlere sahip olmalıdır:

Anahtar Değer
İçerik Türü uygulama/json
API anahtarı <your-search-service-api-key>, sorgu veya yönetici anahtarı

URI parametreleri aşağıdaki örneğe benzer şekilde dizin adı, belge koleksiyonları, arama komutu ve API sürümüne sahip search service uç noktanızı içermelidir:

https://{{service-name}}.search.windows.net/indexes/hotels-sample/docs/search?api-version=2026-04-01

İstek gövdesi geçerli JSON olarak oluşturulmalıdır:

{
    "search": "*",
    "queryType": "full",
    "select": "HotelId, HotelName, Category, Tags, Description",
    "count": true
}
  • search * olarak ayarlanır, null veya boş aramaya eşdeğer belirtilmemiş bir sorgudur. Özellikle kullanışlı değildir, ancak yapabileceğiniz en basit aramadır ve dizindeki tüm alınabilir alanları ve tüm değerleri gösterir.

  • queryTypetam olarak ayarlanır, tam Lucene sorgu ayrıştırıcısını çağırır ve bu söz dizimi için gereklidir.

  • select virgülle ayrılmış bir alan listesi olarak ayarlanmışsa, arama sonucu oluşturma işlemi için yalnızca arama sonuçları bağlamında yararlı olan alanlar da dahil olmak üzere kullanılır.

  • count arama ölçütleriyle eşleşen belge sayısını döndürür. Arama dizesi boş olduğunda, dizindeki tüm belgelerin sayısı alınır (hotels-sample dizininde bu sayı 50'dir).

Belirli alanlara uygulanmış arama kapsamları, gömülü arama ifadelerini tek tek belirli bir alana yönlendirir. Bu örnek, içinde otel terimi olan ancak motel olmayan otel adlarını arar. kullanarak ANDbirden çok alan belirtebilirsiniz.

Bu sorgu söz dizimini kullandığınızda, sorgulamak istediğiniz alanlar arama ifadesinin içinde olduğunda parametresini atlayabilirsiniz searchFields . Alanlı aramada searchFields'i eklerseniz, fieldName:searchExpression her zaman searchFields'den önceliklidir.

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
}

Bu sorgunun yanıtı, Boutique üzerinde filtrelenmiş aşağıdaki örneğe benzer şekilde görünmelidir ve adında otel geçen otelleri döndürürken, adında motel geçen sonuçları hariç tutmalıdır.

{
  "@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"
    }
  ]
}

Arama ifadesi, isteğe bağlı olarak Boole işleçleriyle tek bir terim veya tümcecik ya da parantez içinde daha karmaşık bir ifade olabilir. Bazı örnekler şunlardır:

  • HotelName:(hotel NOT motel)
  • Address/StateProvince:("WA" OR "CA")
  • Tags:("free wifi" NOT "free parking") AND "coffee in lobby"

Her iki dizenin de tek bir varlık olarak değerlendirilmesini istiyorsanız, Address/StateProvince alanında iki farklı konumu ararken yaptığınız gibi bir ifadenizi tırnak içine aldığınızdan emin olun. İstemciye bağlı olarak, tırnak işaretlerini (\) kaçırmanız gerekebilir.

içinde fieldName:searchExpression belirtilen alan aranabilir bir alan olmalıdır. Alan tanımlarının nasıl özniteliklendirildiğini öğrenmek için bkz . Dizin Oluşturma (REST API).

Bulanık arama, yanlış yazılmış kelimeler dahil olmak üzere benzer terimleri eşleştirir. Benzer bir arama yapmak için, tek bir kelimenin sonuna, düzenleme mesafesini belirten 0 ile 2 arasında bir değere sahip isteğe bağlı bir parametre ile birlikte tilde ~ simgesini ekleyin. Örneğin, blue~ veya blue~1 mavi, blues ve tutkal döndürür.

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
}

Bu sorgunun yanıtı, kısalık için kırpılmış eşleşen belgelerde concierge olarak çözümlenir:

{
  "@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"
      ]
    },
. . .
  ]
}

Tümcecikler doğrudan desteklenmez, ancak search=Tags:landy~ AND sevic~ gibi çok parçalı tümceciklerin her bir teriminde bulanık bir eşleşme belirtebilirsiniz. Bu sorgu ifadesi çamaşırhane hizmetinde 15 eşleşme bulur.

Not

Bulanık sorgular analiz edilmez. Tamamlanmamış terimlere sahip sorgu türleri (ön ek sorgusu, joker sorgu, regex sorgusu, belirsiz sorgu) doğrudan sorgu ağacına eklenir ve analiz aşaması atlanır. Kısmi sorgu terimlerinde yapılan tek dönüştürme, küçük harfe dönüştürülmesidir.

Yakınlık araması, belgede birbirine yakın terimleri bulur. İfadenin sonuna bir tilde ~ simgesi ve ardından yakınlık sınırı olan sözcük sayısını ekleyin.

Bu sorgu, bir belgede birbirinin beş sözcüğü içinde otel ve havaalanı terimlerini arar. İfade korunacak şekilde tırnak işaretleri kaçış karakteri ile korunur (\"):

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
}

Bu sorgunun yanıtı aşağıdaki örneğe benzer olmalıdır:

{
  "@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."
    }
  ]
}

Örnek 4: Terim artırımı

Terim artırma, öne çıkarılmış terimi içeren bir belgeyi, terimi içermeyen belgelere göre daha yüksek derecelendirmeyi ifade eder. Bir terimi artırmak için, aradığınız terimin sonuna bir destek faktörü (bir sayı) ile birlikte şapka sembolünü (^) ekleyin. Yükseltme faktörü varsayılanı 1'dir ve pozitif olması gerekse de 1'den az olabilir (örneğin, 0,2). Terim artırma, puanlama profillerinin belirli terimler yerine belirli alanları artırması açısından puanlama profillerinden farklıdır.

Bu before sorgusunda beach access için arama yapın ve bir veya iki terimle eşleşen altı belge olduğuna dikkat edin.

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
}

Aslında, access üzerinde yalnızca iki belge eşleşmektedir. İlk örnek, belgede plaj terimi eksik olsa bile ikinci konumdadır.

{
  "@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"
      ]
    }
  ]
}

after sorgusunda, aramayı tekrar gerçekleştirin, bu kez sahil terimine erişim terimine göre daha fazla öncelik vererek sonuçları iyileştirin. Sorgunun okunabilir bir sürümü search=Description:beach^2 access. İstemcinize bağlı olarak ^2 ifadesini %5E2 olarak ifade etmeniz gerekebilir.

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
}

Siz plaj terimini güçlendirdikten sonra Campus Commander Hotel'de maç beşinci sıraya iner.

{
  "@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"
      ]
    }
  ]
}

Örnek 5: Regex

Düzenli ifade araması, / arasındaki içerik ve küçük harf dizeleri temelinde bir eşleşmeyi bulur ve bu durum RegExp sınıfında belirtildiği gibi belgelenmiştir.

POST /indexes/hotel-samples-index/docs/search?api-version=2026-04-01
{
    "search": "HotelName:/(Mo|Ho)tel/",
    "queryType": "full",
    "select": "HotelName",
    "count": true
}

Bu sorgunun yanıtı aşağıdaki örneğe benzer görünmelidir (kısa olması için kırpılmıştır):

{
  "@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"
    }
  ]
}

Not

Regex sorguları analiz edilmez. Kısmi sorgu terimlerinde yapılan tek dönüştürme, küçük harfe dönüştürülmesidir.

Birden çok (*) veya tek (?) karakterli joker karakter aramaları için genel olarak kabul edilen söz dizimini kullanabilirsiniz. Lucene sorgu ayrıştırıcısı, bu simgelerin bir tümcecikle değil tek bir terimle kullanılmasını destekler.

Bu sorguda, sc ön ekini içeren otel adlarını arayın. Aramanın ilk karakteri olarak * veya ? simgelerinden birini kullanamazsınız.

POST /indexes/hotel-samples-index/docs/search?api-version=2026-04-01
{
    "search": "HotelName:sc*",
    "queryType": "full",
    "select": "HotelName",
    "count": true
}

Bu sorgunun yanıtı aşağıdaki örneğe benzer olmalıdır:

{
  "@odata.count": 1,
  "value": [
    {
      "@search.score": 1,
      "HotelName": "Waterfront Scottish Inn"
    }
  ]
}

Not

Joker karakter sorguları analiz edilmiyor. Kısmi sorgu terimlerinde yapılan tek dönüştürme, küçük harfe dönüştürülmesidir.