Hızlı Başlangıç: REST kullanarak vektör araması
Azure AI Search'te vektör oluşturmak, yüklemek ve sorgulamak için Arama REST API'lerini kullanmayı öğrenin.
Azure AI Search'te vektör deposu vektör ve nonvector alanlarını tanımlayan bir dizin şemasına, ekleme alanını oluşturan algoritmalar için vektör yapılandırmasına ve sorgu isteklerinde kullanılan vektör alanı tanımlarındaki ayarlara sahiptir. Dizin Oluştur API'si vektör deposunu oluşturur.
Azure aboneliğiniz yoksa başlamadan önce ücretsiz bir hesap oluşturun.
Not
Bu hızlı başlangıç vektörleştirme adımını atlar ve örnek belgelere eklemeler sağlar. Kendi içeriğinizin üzerine yerleşik veri öbekleme ve vektörleştirme eklemek istiyorsanız, uçtan uca izlenecek yol için Verileri içeri aktarma ve vektörleştirme sihirbazını deneyin.
Önkoşullar
REST istemcisi ile Visual Studio Code. Başlarken yardıma ihtiyacınız varsa bkz . Hızlı Başlangıç: REST kullanarak metin araması.
Azure AI Search, herhangi bir bölgede ve herhangi bir katmanda. Bu hızlı başlangıç için Ücretsiz katmanını kullanabilirsiniz, ancak daha büyük veri dosyaları için Temel veya üzeri önerilir. Geçerli aboneliğinizin altında mevcut bir Azure AI Search kaynağı oluşturun veya bulun.
Mevcut hizmetlerin çoğu vektör arama desteği sunar. Ocak 2019'den önce oluşturulan hizmetlerin küçük bir alt kümesi için vektör alanlarını içeren bir dizin oluşturma işleminde başarısız olur. Bu durumda yeni bir hizmet oluşturulmalıdır.
İsteğe bağlı olarak, semantik yeniden boyutlandırmayı çağıran sorgu örneğini çalıştırmak için, arama hizmetinizin anlam derecesini etkinleştirilmiş temel katman veya üzeri olması gerekir.
İsteğe bağlı olarak, dağıtımı olan bir Azure OpenAI kaynağı.
text-embedding-ada-002
Kaynak.rest
dosya, yeni metin eklemeleri oluşturmak için isteğe bağlı bir adım içerir, ancak bu bağımlılığı atlayabilmek için önceden oluşturulmuş eklemeler sağlarız.
Dosyaları indirme
Bu hızlı başlangıçta istekleri göndermek için GitHub'dan bir REST örneği indirin. Daha fazla bilgi için bkz . GitHub'dan dosya indirme.
Ayrıca, bu makaledeki yönergeleri kullanarak yerel sisteminizde yeni bir dosya başlatabilir ve istekleri el ile oluşturabilirsiniz.
Arama hizmeti uç noktası alma
Arama hizmeti uç noktasını Azure portalında bulabilirsiniz.
Azure portalında oturum açın ve arama hizmetinizi bulun.
Genel Bakış giriş sayfasında URL'yi bulun. Örnek uç nokta
https://mydemo.search.windows.net
şeklinde görünebilir.
Bu uç noktayı .rest
sonraki bir adımda veya .http
dosyasına yapıştıracaksınız.
Erişimi yapılandırma
Arama uç noktasına yönelik isteklerin kimliği doğrulanmış ve yetkilendirilmiş olmalıdır. Bu görev için API anahtarlarını veya rollerini kullanabilirsiniz. Anahtarları kullanmaya başlamak daha kolaydır, ancak roller daha güvenlidir.
Rol tabanlı bir bağlantı için aşağıdaki yönergeler, istemci uygulamasının kimliğiyle değil, kimliğinizin altında Azure AI Search'e bağlanmanızı içerir.
1. Seçenek: Tuşları kullanma
Ayarlar>Anahtarları'nı seçin ve ardından bir yönetici anahtarı kopyalayın. Yönetici anahtarları nesneleri eklemek, değiştirmek ve silmek için kullanılır. Değiştirilebilir iki yönetici anahtarı vardır. İkisini de kopyalayın. Daha fazla bilgi için bkz . Anahtar kimlik doğrulaması kullanarak Azure AI Search'e bağlanma.
Bu anahtarı .rest
sonraki bir adımda veya .http
dosyasına yapıştıracaksınız.
2. Seçenek: Rolleri kullanma
Arama hizmetinizin rol tabanlı erişim için yapılandırıldığından emin olun. Geliştirici erişimi için önceden yapılandırılmış rol atamalarınız olmalıdır. Rol atamalarınızın arama dizini oluşturma, yükleme ve sorgulama izni vermesi gerekir.
Bu bölümde Azure CLI, Azure PowerShell veya Azure portalını kullanarak kişisel kimlik belirtecinizi alın.
Azure CLI'da oturum açın.
az login
Kişisel kimlik belirtecinizi alın.
az account get-access-token --scope https://search.azure.com/.default
Kişisel kimlik belirtecinizi .rest
sonraki bir adımda veya .http
dosyasına yapıştırıyorsunuz.
Not
Bu bölümde, sizin yerinize Azure AI Search'e bağlanan yerel bir istemci kullandığınız varsayılır. Alternatif bir yaklaşım, uygulamanızın Microsoft Entra ID'ye kayıtlı olduğu varsayılarak istemci uygulaması için belirteç almaktır.
Vektör dizini oluşturma
Dizin Oluştur (REST), bir vektör dizini oluşturur ve arama hizmetinizdeki fiziksel veri yapılarını ayarlar.
Dizin şeması otel içeriğine göre düzenlenmiştir. Örnek veriler vektör ve seçici olmayan adlardan ve yedi kurgusal otelin açıklamalarından oluşur. Bu şema, vektör dizin oluşturma ve sorgular için yapılandırmaları ve anlamsal derecelendirmeyi içerir.
Visual Studio Code'da yeni bir metin dosyası açın.
Değişkenleri daha önce topladığınız değerlere ayarlayın. Bu örnekte kişisel kimlik belirteci kullanılır.
@baseUrl = PUT-YOUR-SEARCH-SERVICE-URL-HERE @token = PUT-YOUR-PERSONAL-IDENTITY-TOKEN-HERE
Dosyayı veya
.rest
.http
dosya uzantısıyla kaydedin.Arama hizmetinizde dizini oluşturmak
hotels-vector-quickstart
için aşağıdaki örneği yapıştırın.### Create a new index POST {{baseUrl}}/indexes?api-version=2023-11-01 HTTP/1.1 Content-Type: application/json Authorization: Bearer {{token}} { "name": "hotels-vector-quickstart", "fields": [ { "name": "HotelId", "type": "Edm.String", "searchable": false, "filterable": true, "retrievable": true, "sortable": false, "facetable": false, "key": true }, { "name": "HotelName", "type": "Edm.String", "searchable": true, "filterable": false, "retrievable": true, "sortable": true, "facetable": false }, { "name": "HotelNameVector", "type": "Collection(Edm.Single)", "searchable": true, "retrievable": true, "dimensions": 1536, "vectorSearchProfile": "my-vector-profile" }, { "name": "Description", "type": "Edm.String", "searchable": true, "filterable": false, "retrievable": true, "sortable": false, "facetable": false }, { "name": "DescriptionVector", "type": "Collection(Edm.Single)", "searchable": true, "retrievable": true, "dimensions": 1536, "vectorSearchProfile": "my-vector-profile" }, { "name": "Category", "type": "Edm.String", "searchable": true, "filterable": true, "retrievable": true, "sortable": true, "facetable": true }, { "name": "Tags", "type": "Collection(Edm.String)", "searchable": true, "filterable": true, "retrievable": true, "sortable": false, "facetable": true }, { "name": "Address", "type": "Edm.ComplexType", "fields": [ { "name": "City", "type": "Edm.String", "searchable": true, "filterable": true, "retrievable": true, "sortable": true, "facetable": true }, { "name": "StateProvince", "type": "Edm.String", "searchable": true, "filterable": true, "retrievable": true, "sortable": true, "facetable": true } ] }, { "name": "Location", "type": "Edm.GeographyPoint", "searchable": false, "filterable": true, "retrievable": true, "sortable": true, "facetable": false } ], "vectorSearch": { "algorithms": [ { "name": "my-hnsw-vector-config-1", "kind": "hnsw", "hnswParameters": { "m": 4, "efConstruction": 400, "efSearch": 500, "metric": "cosine" } }, { "name": "my-hnsw-vector-config-2", "kind": "hnsw", "hnswParameters": { "m": 4, "metric": "euclidean" } }, { "name": "my-eknn-vector-config", "kind": "exhaustiveKnn", "exhaustiveKnnParameters": { "metric": "cosine" } } ], "profiles": [ { "name": "my-vector-profile", "algorithm": "my-hnsw-vector-config-1" } ] }, "semantic": { "configurations": [ { "name": "my-semantic-config", "prioritizedFields": { "titleField": { "fieldName": "HotelName" }, "prioritizedContentFields": [ { "fieldName": "Description" } ], "prioritizedKeywordsFields": [ { "fieldName": "Tags" } ] } } ] } }
İstek gönder’i seçin. İstek göndermek için REST istemcisine ihtiyacınız olduğunu hatırlayın. Bir yanıtınız
HTTP/1.1 201 Created
olmalıdır. Yanıt gövdesi dizin şemasının JSON gösterimini içermelidir.Önemli noktalar:
- Koleksiyon,
fields
metin ve vektör araması için gerekli bir anahtar alanı ile metin ve vektör alanları (ve gibiDescription
DescriptionVector
) içerir. Vektör ve nonvector alanlarının aynı dizinde birlikte bulunması karma sorguları etkinleştirir. Örneğin, filtreleri, metin aramasını anlam derecelendirmesiyle ve vektörleri tek bir sorgu işleminde birleştirebilirsiniz. - Vektör alanları ve
vectorSearchProfile
özellikleriyledimensions
olmalıdırtype: Collection(Edm.Single)
. vectorSearch
bölümü, yaklaşık en yakın komşu algoritma yapılandırmalarından ve profillerinden oluşan bir dizidir. Desteklenen algoritmalar hiyerarşik gezinilebilir küçük dünya ve en kapsamlı k-en yakın komşu içerir. Daha fazla bilgi için bkz . Vektör aramasında ilgi puanlaması.- [İsteğe bağlı]: Yapılandırma
semantic
, arama sonuçlarının yeniden yapılandırılmasını sağlar. Sonuçları, yapılandırmada belirtilen dize alanları için türündesemantic
sorgular halinde yeniden düzenleyebilirsiniz. Daha fazla bilgi edinmek için bkz . Anlam derecelendirmesine genel bakış.
- Koleksiyon,
Belgeleri karşıya yükle
Dizini oluşturma ve yükleme ayrı adımlardır. Azure AI Search'te dizin, arama hizmetinde çalıştırılacak tüm aranabilir verileri ve sorguları içerir. REST çağrıları için veriler JSON belgeleri olarak sağlanır. Bu görev için Belgeler- Dizin REST API'sini kullanın.
URI, koleksiyonu ve işlemi içerecek docs
şekilde genişletilir index
.
Önemli
Aşağıdaki örnek çalıştırılabilir kod değildir. Okunabilirlik için, her biri bu makale için çok uzun olan 1.536 ekleme içerdiği için vektör değerlerini dışladık. Bu adımı denemek istiyorsanız GitHub'da bulunan örnekten çalıştırılabilir kodu kopyalayın.
### Upload documents
POST {{baseUrl}}/indexes/hotels-quickstart-vectors/docs/index?api-version=2023-11-01 HTTP/1.1
Content-Type: application/json
Authorization: Bearer {{token}}
{
"value": [
{
"@search.action": "mergeOrUpload",
"HotelId": "1",
"HotelName": "Secret Point Motel",
"HotelNameVector": [VECTOR ARRAY OMITTED],
"Description":
"The hotel is ideally located on the main commercial artery of the city
in the heart of New York.",
"DescriptionVector": [VECTOR ARRAY OMITTED],
"Category": "Boutique",
"Tags": [
"pool",
"air conditioning",
"concierge"
],
},
{
"@search.action": "mergeOrUpload",
"HotelId": "2",
"HotelName": "Twin Dome Hotel",
"HotelNameVector": [VECTOR ARRAY OMITTED],
"Description":
"The hotel is situated in a nineteenth century plaza, which has been
expanded and renovated to the highest architectural standards to create a modern,
functional and first-class hotel in which art and unique historical elements
coexist with the most modern comforts.",
"DescriptionVector": [VECTOR ARRAY OMITTED],
"Category": "Boutique",
"Tags": [
"pool",
"air conditioning",
"free wifi",
"concierge"
]
},
{
"@search.action": "mergeOrUpload",
"HotelId": "3",
"HotelName": "Triple Landscape Hotel",
"HotelNameVector": [VECTOR ARRAY OMITTED],
"Description":
"The Hotel stands out for its gastronomic excellence under the management of
William Dough, who advises on and oversees all of the Hotel’s restaurant services.",
"DescriptionVector": [VECTOR ARRAY OMITTED],
"Category": "Resort and Spa",
"Tags": [
"air conditioning",
"bar",
"continental breakfast"
]
}
{
"@search.action": "mergeOrUpload",
"HotelId": "4",
"HotelName": "Sublime Cliff Hotel",
"HotelNameVector": [VECTOR ARRAY OMITTED],
"Description":
"Sublime Cliff Hotel is located in the heart of the historic center of
Sublime in an extremely vibrant and lively area within short walking distance to
the sites and landmarks of the city and is surrounded by the extraordinary beauty
of churches, buildings, shops and monuments.
Sublime Cliff is part of a lovingly restored 1800 palace.",
"DescriptionVector": [VECTOR ARRAY OMITTED],
"Category": "Boutique",
"Tags": [
"concierge",
"view",
"24-hour front desk service"
]
},
{
"@search.action": "mergeOrUpload",
"HotelId": "13",
"HotelName": "Historic Lion Resort",
"HotelNameVector": [VECTOR ARRAY OMITTED],
"Description":
"Unmatched Luxury. Visit our downtown hotel to indulge in luxury
accommodations. Moments from the stadium, we feature the best in comfort",
"DescriptionVector": [VECTOR ARRAY OMITTED],
"Category": "Resort and Spa",
"Tags": [
"view",
"free wifi",
"pool"
]
},
{
"@search.action": "mergeOrUpload",
"HotelId": "48",
"HotelName": "Nordicks Hotel",
"HotelNameVector": [VECTOR ARRAY OMITTED],
"Description":
"Only 90 miles (about 2 hours) from the nation's capital and nearby
most everything the historic valley has to offer. Hiking? Wine Tasting? Exploring
the caverns? It's all nearby and we have specially priced packages to help make
our B&B your home base for fun while visiting the valley.",
"DescriptionVector": [VECTOR ARRAY OMITTED],
"Category": "Boutique",
"Tags": [
"continental breakfast",
"air conditioning",
"free wifi"
],
},
{
"@search.action": "mergeOrUpload",
"HotelId": "49",
"HotelName": "Old Carrabelle Hotel",
"HotelNameVector": [VECTOR ARRAY OMITTED],
"Description":
"Spacious rooms, glamorous suites and residences, rooftop pool, walking
access to shopping, dining, entertainment and the city center.",
"DescriptionVector": [VECTOR ARRAY OMITTED],
"Category": "Luxury",
"Tags": [
"air conditioning",
"laundry service",
"24-hour front desk service"
]
}
]
}
Önemli noktalar:
- Yükteki belgeler, dizin şemasında tanımlanan alanlardan oluşur.
- Vektör alanları kayan nokta değerleri içerir. Dimensions özniteliğinin her biri en az 2, en fazla 3.072 kayan nokta değeri vardır. Bu hızlı başlangıç, Azure OpenAI text-embedding-ada-002 modeli tarafından oluşturulan eklemelerin boyutu olduğundan dimensions özniteliğini 1.536 olarak ayarlar.
Sorgu çalıştırma
Belgeler artık yüklendiklerine göre Belgeler - Arama Gönderisi (REST) kullanarak bunlara yönelik vektör sorguları gönderebilirsiniz.
Çeşitli desenleri göstermek için birkaç sorgu vardır:
Bu bölümdeki vektör sorguları iki dizeyi temel alır:
- Arama dizesi:
historic hotel walk to restaurants and shopping
- Vektör sorgu dizesi (matematiksel bir gösterime vektörleştirilmiş):
classic lodging near running trails, eateries, retail
Vektör sorgu dizesi, arama dizesine benzer, ancak arama dizininde mevcut olmayan terimleri içerir. için classic lodging near running trails, eateries, retail
anahtar sözcük araması yaparsanız sonuçlar sıfır olur. Eşleşen terimler olmasa bile ilgili sonuçları nasıl alabileceğinizi göstermek için bu örneği kullanırız.
Önemli
Aşağıdaki örnekler çalıştırılabilir kod değildir. Okunabilirlik için, her dizi bu makale için çok uzun olan 1.536 ekleme içerdiği için vektör değerlerini dışladık. Bu sorguları denemek istiyorsanız, GitHub'da örnekten çalıştırılabilir kodu kopyalayın.
Tek vektör arama
Arama dizinini sorgulamak için bir POST isteği yapıştırın. Ardından İstek gönder'i seçin. URI, işlecini içerecek şekilde genişletilir
/docs/search
.### Run a query POST {{baseUrl}}/indexes/hotels-vector-quickstart/docs/search?api-version=2023-11-01 HTTP/1.1 Content-Type: application/json Authorization: Bearer {{token}} { "count": true, "select": "HotelId, HotelName, Description, Category", "vectorQueries": [ { "vector"": [0.01944167, 0.0040178085 . . . TRIMMED FOR BREVITY 010858015, -0.017496133], "k": 7, "fields": "DescriptionVector", "kind": "vector", "exhaustive": true } ] }
Bu vektör sorgusu kısaldı. ,
vectorQueries.vector
sorgu girişinin vektörleştirilmiş metnini içerir,fields
hangi vektör alanlarının arandığını belirler vek
döndürülecek en yakın komşu sayısını belirtir.Vektör sorgu dizesi,
classic lodging near running trails, eateries, retail
bu sorgu için 1.536 eklemeye vektörleştirilmiş olan dizesidir.Yanıtı gözden geçirin. vektör eşdeğeri
classic lodging near running trails, eateries, retail
için yanıt yedi sonuç içerir. Her sonuç bir arama puanı ve içindeselect
listelenen alanları sağlar. Benzerlik aramasında yanıtta her zaman değer benzerlik puanına göre sıralanmış sonuçlar bulunurk
.{ "@odata.context": "https://my-demo-search.search.windows.net/indexes('hotels-vector-quickstart')/$metadata#docs(*)", "@odata.count": 7, "value": [ { "@search.score": 0.857736, "HotelName": "Nordick's Motel", "Description": "Only 90 miles (about 2 hours) from the nation's capital and nearby most everything the historic valley has to offer. Hiking? Wine Tasting? Exploring the caverns? It's all nearby and we have specially priced packages to help make our B&B your home base for fun while visiting the valley." }, { "@search.score": 0.8399129, "HotelName": "Old Carrabelle Hotel", "Description": "Spacious rooms, glamorous suites and residences, rooftop pool, walking access to shopping, dining, entertainment and the city center." }, { "@search.score": 0.8383954, "HotelName": "Historic Lion Resort", "Description": "Unmatched Luxury. Visit our downtown hotel to indulge in luxury accommodations. Moments from the stadium, we feature the best in comfort" }, { "@search.score": 0.8254346, "HotelName": "Sublime Cliff Hotel", "Description": "Sublime Cliff Hotel is located in the heart of the historic center of Sublime in an extremely vibrant and lively area within short walking distance to the sites and landmarks of the city and is surrounded by the extraordinary beauty of churches, buildings, shops and monuments. Sublime Cliff is part of a lovingly restored 1800 palace." }, { "@search.score": 0.82380056, "HotelName": "Secret Point Hotel", "Description": "The hotel is ideally located on the main commercial artery of the city in the heart of New York." }, { "@search.score": 0.81514084, "HotelName": "Twin Dome Hotel", "Description": "The hotel is situated in a nineteenth century plaza, which has been expanded and renovated to the highest architectural standards to create a modern, functional and first-class hotel in which art and unique historical elements coexist with the most modern comforts." }, { "@search.score": 0.8133763, "HotelName": "Triple Landscape Hotel", "Description": "The Hotel stands out for its gastronomic excellence under the management of William Dough, who advises on and oversees all of the Hotel’s restaurant services." } ] }
Filtre ile tek vektör araması
Filtreler ekleyebilirsiniz, ancak filtreler dizininizdeki görsel olmayan içeriğe uygulanır. Bu örnekte filtre, ücretsiz Wi-Fi sağlamayan Tags
otelleri filtrelemek için alana uygulanır.
Arama dizinini sorgulamak için bir POST isteği yapıştırın.
### Run a vector query with a filter POST {{baseUrl}}/indexes/hotels-vector-quickstart/docs/search?api-version=2023-11-01 HTTP/1.1 Content-Type: application/json Authorization: Bearer {{token}} { "count": true, "select": "HotelId, HotelName, Category, Tags, Description", "filter": "Tags/any(tag: tag eq 'free wifi')", "vectorFilterMode": "postFilter", "vectorQueries": [ { "vector": [ VECTOR OMITTED ], "k": 7, "fields": "DescriptionVector", "kind": "vector", "exhaustive": true }, ] }
Yanıtı gözden geçirin. Sorgu önceki örnekle aynıdır, ancak işlem sonrası dışlama filtresi içerir ve yalnızca ücretsiz Wi-Fi erişimi olan üç oteli döndürür.
{ "@odata.count": 3, "value": [ { "@search.score": 0.857736, "HotelName": "Nordick's Motel", "Description": "Only 90 miles (about 2 hours) from the nation's capital and nearby most everything the historic valley has to offer. Hiking? Wine Tasting? Exploring the caverns? It's all nearby and we have specially priced packages to help make our B&B your home base for fun while visiting the valley.", "Tags": [ "continental breakfast", "air conditioning", "free wifi" ] }, { "@search.score": 0.8383954, "HotelName": "Historic Lion Resort", "Description": "Unmatched Luxury. Visit our downtown hotel to indulge in luxury accommodations. Moments from the stadium, we feature the best in comfort", "Tags": [ "view", "free wifi", "pool" ] }, { "@search.score": 0.81514084, "HotelName": "Twin Dome Hotel", "Description": "The hotel is situated in a nineteenth century plaza, which has been expanded and renovated to the highest architectural standards to create a modern, functional and first-class hotel in which art and unique historical elements coexist with the most modern comforts.", "Tags": [ "pool", "free wifi", "concierge" ] } ] }
Karma arama
Karma arama, tek bir arama isteğindeki anahtar sözcük sorgularından ve vektör sorgularından oluşur. Bu örnek vektör sorgusunu ve tam metin aramasını eşzamanlı olarak çalıştırır:
- Arama dizesi:
historic hotel walk to restaurants and shopping
- Vektör sorgu dizesi (matematiksel bir gösterime vektörleştirilmiş):
classic lodging near running trails, eateries, retail
Arama dizinini sorgulamak için bir POST isteği yapıştırın. Ardından İstek gönder'i seçin.
### Run a hybrid query POST {{baseUrl}}/indexes/hotels-vector-quickstart/docs/search?api-version=2023-11-01 HTTP/1.1 Content-Type: application/json Authorization: Bearer {{token}} { "count": true, "search": "historic hotel walk to restaurants and shopping", "select": "HotelName, Description", "top": 7, "vectorQueries": [ { "vector": [ VECTOR OMITTED], "k": 7, "fields": "DescriptionVector", "kind": "vector", "exhaustive": true } ] }
Bu bir karma sorgu olduğundan sonuçlar Reciprocal Rank Fusion (RRF) tarafından derecelenir. RRF, birden çok arama sonucunun arama puanlarını değerlendirir, tersini alır ve ardından birleştirilmiş sonuçları birleştirip sıralar. Sonuç
top
sayısı döndürülür.Yanıtı gözden geçirin.
{ "@odata.count": 7, "value": [ { "@search.score": 0.03279569745063782, "HotelName": "Historic Lion Resort", "Description": "Unmatched Luxury. Visit our downtown hotel to indulge in luxury accommodations. Moments from the stadium, we feature the best in comfort" }, { "@search.score": 0.03226646035909653, "HotelName": "Sublime Cliff Hotel", "Description": "Sublime Cliff Hotel is located in the heart of the historic center of Sublime in an extremely vibrant and lively area within short walking distance to the sites and landmarks of the city and is surrounded by the extraordinary beauty of churches, buildings, shops and monuments. Sublime Cliff is part of a lovingly restored 1800 palace." }, { "@search.score": 0.03226646035909653, "HotelName": "Old Carrabelle Hotel", "Description": "Spacious rooms, glamorous suites and residences, rooftop pool, walking access to shopping, dining, entertainment and the city center." }, { "@search.score": 0.03205128386616707, "HotelName": "Nordick's Motel", "Description": "Only 90 miles (about 2 hours) from the nation's capital and nearby most everything the historic valley has to offer. Hiking? Wine Tasting? Exploring the caverns? It's all nearby and we have specially priced packages to help make our B&B your home base for fun while visiting the valley." }, { "@search.score": 0.03128054738044739, "HotelName": "Triple Landscape Hotel", "Description": "The Hotel stands out for its gastronomic excellence under the management of William Dough, who advises on and oversees all of the Hotel’s restaurant services." }, { "@search.score": 0.03100961446762085, "HotelName": "Twin Dome Hotel", "Description": "The hotel is situated in a nineteenth century plaza, which has been expanded and renovated to the highest architectural standards to create a modern, functional and first-class hotel in which art and unique historical elements coexist with the most modern comforts." }, { "@search.score": 0.03077651560306549, "HotelName": "Secret Point Hotel", "Description": "The hotel is ideally located on the main commercial artery of the city in the heart of New York." } ] }
RRF sonuçları birleştirdiğinden girişlerin gözden geçirilmesine yardımcı olur. Aşağıdaki sonuçlar yalnızca tam metin sorgusundan alınıyor. En iyi iki sonuç Sublime Cliff Hotel ve History Lion Resort oldu. Sublime Cliff Hotel daha güçlü bir BM25 ilgi puanına sahiptir.
{ "@search.score": 2.2626662, "HotelName": "Sublime Cliff Hotel", "Description": "Sublime Cliff Hotel is located in the heart of the historic center of Sublime in an extremely vibrant and lively area within short walking distance to the sites and landmarks of the city and is surrounded by the extraordinary beauty of churches, buildings, shops and monuments. Sublime Cliff is part of a lovingly restored 1800 palace." }, { "@search.score": 0.86421645, "HotelName": "Historic Lion Resort", "Description": "Unmatched Luxury. Visit our downtown hotel to indulge in luxury accommodations. Moments from the stadium, we feature the best in comfort" },
Eşleşmeleri bulmak için HNSW kullanan yalnızca vektör sorgusunda Sublime Cliff Hotel dördüncü konuma düşüyor. Tam metin aramasında ikinci, vektör aramasında üçüncü sırada yer alan Historic Lion aynı dalgalanma aralığını yaşamadığından homojenleştirilmiş sonuç kümesinde üst eşleşme olarak görünür.
"value": [ { "@search.score": 0.857736, "HotelId": "48", "HotelName": "Nordick's Motel", "Description": "Only 90 miles (about 2 hours) from the nation's capital and nearby most everything the historic valley has to offer. Hiking? Wine Tasting? Exploring the caverns? It's all nearby and we have specially priced packages to help make our B&B your home base for fun while visiting the valley.", "Category": "Boutique" }, { "@search.score": 0.8399129, "HotelId": "49", "HotelName": "Old Carrabelle Hotel", "Description": "Spacious rooms, glamorous suites and residences, rooftop pool, walking access to shopping, dining, entertainment and the city center.", "Category": "Luxury" }, { "@search.score": 0.8383954, "HotelId": "13", "HotelName": "Historic Lion Resort", "Description": "Unmatched Luxury. Visit our downtown hotel to indulge in luxury accommodations. Moments from the stadium, we feature the best in comfort", "Category": "Resort and Spa" }, { "@search.score": 0.8254346, "HotelId": "4", "HotelName": "Sublime Cliff Hotel", "Description": "Sublime Cliff Hotel is located in the heart of the historic center of Sublime in an extremely vibrant and lively area within short walking distance to the sites and landmarks of the city and is surrounded by the extraordinary beauty of churches, buildings, shops and monuments. Sublime Cliff is part of a lovingly restored 1800 palace.", "Category": "Boutique" }, { "@search.score": 0.82380056, "HotelId": "1", "HotelName": "Secret Point Hotel", "Description": "The hotel is ideally located on the main commercial artery of the city in the heart of New York.", "Category": "Boutique" }, { "@search.score": 0.81514084, "HotelId": "2", "HotelName": "Twin Dome Hotel", "Description": "The hotel is situated in a nineteenth century plaza, which has been expanded and renovated to the highest architectural standards to create a modern, functional and first-class hotel in which art and unique historical elements coexist with the most modern comforts.", "Category": "Boutique" }, { "@search.score": 0.8133763, "HotelId": "3", "HotelName": "Triple Landscape Hotel", "Description": "The Hotel stands out for its gastronomic excellence under the management of William Dough, who advises on and oversees all of the Hotel’s restaurant services.", "Category": "Resort and Spa" } ]
Filtre ile anlamsal karma arama
Koleksiyondaki son sorgu aşağıdadır. Semantik derecelendirmeye sahip bu karma sorgu, yalnızca Washington D.C'nin 500 kilometre yarıçapındaki otelleri gösterecek şekilde filtrelenmiştir. Varsayılana eşdeğer olan null olarak ayarlayabilirsiniz vectorFilterMode
(preFilter
daha yeni dizinler ve postFilter
eski dizinler için).
Arama dizinini sorgulamak için bir POST isteği yapıştırın. Ardından İstek gönder'i seçin.
### Run a hybrid query POST {{baseUrl}}/indexes/hotels-vector-quickstart/docs/search?api-version=2023-11-01 HTTP/1.1 Content-Type: application/json Authorization: Bearer {{token}} { "count": true, "search": "historic hotel walk to restaurants and shopping", "select": "HotelId, HotelName, Category, Description,Address/City, Address/StateProvince", "filter": "geo.distance(Location, geography'POINT(-77.03241 38.90166)') le 500", "vectorFilterMode": null, "facets": [ "Address/StateProvince"], "top": 7, "queryType": "semantic", "answers": "extractive|count-3", "captions": "extractive|highlight-true", "semanticConfiguration": "my-semantic-config", "vectorQueries": [ { "vector": [ VECTOR OMITTED ], "k": 7, "fields": "DescriptionVector", "kind": "vector", "exhaustive": true } ] }
Yanıtı gözden geçirin. Yanıt, konuma göre filtrelenen ve
StateProvince
arama dizesi sorgusuna (historic hotel walk to restaurants and shopping
) en yakın sonuçları yükseltmek için modellenen ve görsel olarak yeniden kaydedilen üç oteldir.Eski Carabelle Hotel şimdi en üst noktaya taşınıyor. Semantik sıralama olmadan Nordick's Hotel bir numaradır. Anlamsal derecelendirme ile, makine kavrama modelleri bunu "otel, yemek (restoranlar) ve alışverişe yürüme mesafesinde" için geçerli olduğunu
historic
algılar.{ "@odata.count": 3, "@search.facets": { "Address/StateProvince": [ { "count": 1, "value": "NY" }, { "count": 1, "value": "VA" } ] }, "@search.answers": [], "value": [ { "@search.score": 0.03306011110544205, "@search.rerankerScore": 2.5094974040985107, "HotelId": "49", "HotelName": "Old Carrabelle Hotel", "Description": "Spacious rooms, glamorous suites and residences, rooftop pool, walking access to shopping, dining, entertainment and the city center.", "Category": "Luxury", "Address": { "City": "Arlington", "StateProvince": "VA" } }, { "@search.score": 0.03306011110544205, "@search.rerankerScore": 2.0370211601257324, "HotelId": "48", "HotelName": "Nordick's Motel", "Description": "Only 90 miles (about 2 hours) from the nation's capital and nearby most everything the historic valley has to offer. Hiking? Wine Tasting? Exploring the caverns? It's all nearby and we have specially priced packages to help make our B&B your home base for fun while visiting the valley.", "Category": "Boutique", "Address": { "City": "Washington D.C.", "StateProvince": null } }, { "@search.score": 0.032258063554763794, "@search.rerankerScore": 1.6706111431121826, "HotelId": "1", "HotelName": "Secret Point Hotel", "Description": "The hotel is ideally located on the main commercial artery of the city in the heart of New York.", "Category": "Boutique", "Address": { "City": "New York", "StateProvince": "NY" } } ] }
Önemli noktalar:
- Vektör araması özelliği aracılığıyla
vectors.value
belirtilir. Anahtar sözcük araması özelliği aracılığıylasearch
belirtilir. - Karma aramada, vektör arama ile anahtar sözcükler üzerinde tam metin arama tümleştirebilirsiniz. Filtreler, yazım denetimi ve semantik derecelendirme vektörlere değil yalnızca metin içeriğine uygulanır. Bu son sorguda, sistem yeterince güçlü bir tane üretmediğinden anlamsal
answer
bir şey yoktur. - Gerçek sonuçlar semantik açıklamalı alt yazılar ve vurgular da dahil olmak üzere daha fazla ayrıntı içerir. Sonuçlar okunabilirlik için değiştirildi. Yanıtın tam yapısını almak için isteği REST istemcisinde çalıştırın.
- Vektör araması özelliği aracılığıyla
Temizleme
Kendi aboneliğinizde çalışırken, projenin sonunda oluşturduğunuz kaynaklara hala ihtiyacınız olup olmadığını belirlemek iyi bir fikirdir. Çalışır durumda bırakılan kaynaklar maliyetlerin artmasına neden olabilir. Kaynakları teker teker silebilir veya tüm kaynak grubunu silerek kaynak kümesinin tamamını kaldırabilirsiniz.
En soldaki bölmedeki Tüm kaynaklar veya Kaynak grupları bağlantısını kullanarak portaldaki kaynakları bulabilir ve yönetebilirsiniz.
Şu komutu da deneyebilirsiniz DELETE
:
### Delete an index
DELETE {{baseUrl}}/indexes/hotels-vector-quickstart?api-version=2023-11-01 HTTP/1.1
Content-Type: application/json
Authorization: Bearer {{token}}
Sonraki adımlar
Sonraki adım olarak Python, C# veya JavaScript tanıtım kodunu gözden geçirmenizi öneririz.