Quickstart: Vector search by using REST
Meer informatie over het gebruik van de SEARCH REST API's voor het maken, laden en opvragen van vectoren in Azure AI Search.
In Azure AI Search heeft een vectorarchief een indexschema dat vectorvelden en niet-vectorvelden definieert, een vectorconfiguratie voor algoritmen die de insluitruimte maken en instellingen voor vectorvelddefinities die worden gebruikt in queryaanvragen. De Create Index-API maakt het vectorarchief.
Als u geen Azure-abonnement hebt, maakt u een gratis account voordat u begint.
Notitie
De stabiele 2023-11-01 REST API-versie is afhankelijk van externe oplossingen voor het segmenteren en insluiten van gegevens. Als u de ingebouwde functies voor gegevenssegmentering en vectorisatie (openbare preview) wilt evalueren, kunt u de wizard Gegevens importeren en vectoriseren voor een end-to-end-overzicht.
Vereisten
Visual Studio Code met een REST-client. Als u hulp nodig hebt bij het aan de slag gaan, raadpleegt u snelstartgids: Tekst zoeken met REST.
Azure AI Search, in elke regio en op elke laag. U kunt de gratis laag voor deze quickstart gebruiken, maar Basic of hoger wordt aanbevolen voor grotere gegevensbestanden. Maak of zoek een bestaande Azure AI Search-resource onder uw huidige abonnement.
De meeste bestaande services ondersteunen vectorzoekopdrachten. Voor een kleine subset van services die vóór januari 2019 zijn gemaakt, mislukt het maken van een index die vectorvelden bevat. In dit geval moet er een nieuwe service worden gemaakt.
Als u het queryvoorbeeld wilt uitvoeren dat semantische herrankering aanroept, moet uw zoekservice de Basic-laag of hoger zijn, waarbij semantische rangschikking is ingeschakeld.
Een Azure OpenAI-resource met een implementatie van
text-embedding-ada-002
. Het bronbestand.rest
bevat een optionele stap voor het genereren van nieuwe tekstinsluitingen, maar we bieden vooraf gegenereerde insluitingen, zodat u deze afhankelijkheid weglaat.
Bestanden downloaden
Download een REST-voorbeeld van GitHub om de aanvragen in deze quickstart te verzenden. Zie Bestanden downloaden van GitHub voor meer informatie.
U kunt ook een nieuw bestand op uw lokale systeem starten en handmatig aanvragen maken met behulp van de instructies in dit artikel.
Een zoekservicesleutel en -URL kopiëren
REST-aanroepen vereisen het eindpunt van de zoekservice en een API-sleutel voor elke aanvraag. U kunt deze waarden ophalen uit Azure Portal.
Meld u aan bij het Azure-portaal. Ga naar de pagina Overzicht en kopieer de URL. Een eindpunt ziet er bijvoorbeeld uit als
https://mydemo.search.windows.net
.Selecteer Instellingen> Sleutels en kopieer een beheerderssleutel. Beheer sleutels worden gebruikt om objecten toe te voegen, te wijzigen en te verwijderen. Er zijn twee uitwisselbare beheerderssleutels. Kopieer een van beide.
Een vectorindex maken
Create Index (REST) maakt een vectorindex en stelt de fysieke gegevensstructuren in uw zoekservice in.
Het indexschema is georganiseerd rond hotelinhoud. Voorbeeldgegevens bestaan uit vector- en niet-vectornamen en beschrijvingen van zeven fictieve hotels. Dit schema bevat configuraties voor vectorindexering en query's en voor semantische classificatie.
Open een nieuw tekstbestand in Visual Studio Code.
Stel variabelen in op het zoekeindpunt en de API-sleutel die u eerder hebt verzameld.
@baseUrl = PUT-YOUR-SEARCH-SERVICE-URL-HERE @apiKey = PUT-YOUR-ADMIN-API-KEY-HERE
Sla het bestand op met een
.rest
bestandsextensie.Plak in het volgende voorbeeld om de
hotels-vector-quickstart
index in uw zoekservice te maken.### Create a new index POST {{baseUrl}}/indexes?api-version=2023-11-01 HTTP/1.1 Content-Type: application/json api-key: {{apiKey}} { "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" } ] } } ] } }
Selecteer Verzoek verzenden. Denk eraan dat u de REST-client nodig hebt om aanvragen te verzenden. U moet een
HTTP/1.1 201 Created
antwoord hebben. De hoofdtekst van het antwoord moet de JSON-weergave van het indexschema bevatten.Belangrijke punten:
- De
fields
verzameling bevat een vereist sleutelveld en tekst- en vectorvelden (zoalsDescription
enDescriptionVector
) voor tekst- en vectorzoekopdrachten. Door vectorvelden en niet-vectorvelden in dezelfde index samen te stellen, kunnen hybride query's worden uitgevoerd. U kunt bijvoorbeeld filters, tekstzoekopdrachten combineren met semantische rangschikking en vectoren in één querybewerking. - Vectorvelden moeten met
dimensions
envectorSearchProfile
eigenschappen zijntype: Collection(Edm.Single)
. - De
vectorSearch
sectie is een matrix met configuraties en profielen van het dichtstbijzijnde buuralgoritmen. Ondersteunde algoritmen omvatten hiërarchische bevaarbare kleine wereld en uitgebreide k-dichtstbijzijnde buren. Zie Relevantiescore in vectorzoekopdrachten voor meer informatie. - [Optioneel]: met de
semantic
configuratie kan de zoekresultaten opnieuw worden gerankt. U kunt resultaten opnieuw rangverkennen in query's van het typesemantic
voor tekenreeksvelden die zijn opgegeven in de configuratie. Zie het overzicht van Semantische classificaties voor meer informatie.
- De
Documenten uploaden
Het maken en laden van de index zijn afzonderlijke stappen. In Azure AI Search bevat de index alle doorzoekbare gegevens en query's die worden uitgevoerd op de zoekservice. Voor REST-aanroepen worden de gegevens verstrekt als JSON-documenten. Gebruik Documenten- INDEX REST API voor deze taak.
De URI wordt uitgebreid om de docs
verzameling en de index
bewerking op te nemen.
Belangrijk
Het volgende voorbeeld is geen uitvoerbare code. Voor leesbaarheid hebben we vectorwaarden uitgesloten omdat elke vector 1536 insluitingen bevat, wat te lang is voor dit artikel. Als u deze stap wilt proberen, kopieert u uitvoerbare code uit het voorbeeld op GitHub.
### Upload documents
POST {{baseUrl}}/indexes/hotels-quickstart-vectors/docs/index?api-version=2023-11-01 HTTP/1.1
Content-Type: application/json
api-key: {{apiKey}}
{
"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"
]
}
]
}
Belangrijke punten:
- Documenten in de nettolading bestaan uit velden die zijn gedefinieerd in het indexschema.
- Vectorvelden bevatten drijvendekommawaarden. Het kenmerk Dimensies heeft minimaal 2 en een maximum van 3072 drijvendekommawaarden. In deze quickstart wordt het dimensiekenmerk ingesteld op 1536, omdat dit de grootte is van insluitingen die worden gegenereerd door het open AI-model voor tekst-insluiten-ada-002 .
Query's uitvoeren
Nu documenten zijn geladen, kunt u vectorquery's voor deze query's uitgeven met behulp van Documenten - Zoekpost (REST).
Er zijn verschillende query's om verschillende patronen te demonstreren:
- Zoeken met één vector
- Zoeken met één vector met filter
- Hybride zoekopdracht
- Semantische hybride zoekopdracht met filter
De vectorquery's in deze sectie zijn gebaseerd op twee tekenreeksen:
- Zoekreeks:
historic hotel walk to restaurants and shopping
- Vectorquerytekenreeks (gevectoriseerd in een wiskundige weergave):
classic lodging near running trails, eateries, retail
De vectorquerytekenreeks is semantisch vergelijkbaar met de zoekreeks, maar bevat termen die niet bestaan in de zoekindex. Als u een trefwoord zoekt classic lodging near running trails, eateries, retail
, zijn de resultaten nul. We gebruiken dit voorbeeld om te laten zien hoe u relevante resultaten kunt krijgen, zelfs als er geen overeenkomende termen zijn.
Belangrijk
De volgende voorbeelden zijn geen uitvoerbare code. Voor leesbaarheid hebben we vectorwaarden uitgesloten omdat elke matrix 1536 insluitingen bevat, wat te lang is voor dit artikel. Als u deze query's wilt proberen, kopieert u uitvoerbare code uit het voorbeeld op GitHub.
Zoeken met één vector
Plak een POST-aanvraag om een query uit te voeren op de zoekindex. Selecteer vervolgens Aanvraag verzenden. De URI wordt uitgebreid om de
/docs/search
operator op te nemen.### Run a query POST {{baseUrl}}/indexes/hotels-vector-quickstart/docs/search?api-version=2023-11-01 HTTP/1.1 Content-Type: application/json api-key: {{apiKey}} { "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 } ] }
Deze vectorquery wordt ingekort voor kortheid. De
vectorQueries.vector
bevat de vectortekst van de query-invoer,fields
bepaalt welke vectorvelden worden doorzocht enk
geeft het aantal dichtstbijzijnde buren op dat moet worden geretourneerd.De vectorquerytekenreeks is
classic lodging near running trails, eateries, retail
, die wordt gevectoriseerd in 1536 insluitingen voor deze query.Bekijk het antwoord. Het antwoord voor het vectorequivalent van
classic lodging near running trails, eateries, retail
bevat zeven resultaten. Elk resultaat bevat een zoekscore en de velden die worden vermeld inselect
. In een zoekopdracht naar overeenkomsten bevatk
het antwoord altijd resultaten die zijn gerangschikt op de waarde-overeenkomstscore.{ "@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." } ] }
Zoeken met één vector met filter
U kunt filters toevoegen, maar de filters worden toegepast op de niet-ctorinhoud in uw index. In dit voorbeeld is het filter van toepassing op het Tags
veld om alle hotels te filteren die geen gratis Wi-Fi bieden.
Plak een POST-aanvraag om een query uit te voeren op de zoekindex.
### 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 api-key: {{apiKey}} { "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 }, ] }
Bekijk het antwoord. De query is hetzelfde als in het vorige voorbeeld, maar bevat een uitsluitingsfilter na verwerking en retourneert alleen de drie hotels met gratis Wi-Fi.
{ "@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" ] } ] }
Hybride zoekopdracht
Hybride zoekopdrachten bestaan uit trefwoordquery's en vectorquery's in één zoekaanvraag. In dit voorbeeld wordt de vectorquery en de zoekopdracht in volledige tekst gelijktijdig uitgevoerd:
- Zoekreeks:
historic hotel walk to restaurants and shopping
- Vectorquerytekenreeks (gevectoriseerd in een wiskundige weergave):
classic lodging near running trails, eateries, retail
Plak een POST-aanvraag om een query uit te voeren op de zoekindex. Selecteer vervolgens Aanvraag verzenden.
### Run a hybrid query POST {{baseUrl}}/indexes/hotels-vector-quickstart/docs/search?api-version=2023-11-01 HTTP/1.1 Content-Type: application/json api-key: {{apiKey}} { "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 } ] }
Omdat dit een hybride query is, worden de resultaten gerangschikt op Wederzijdse Rank Fusion (RRF). RRF evalueert zoekscores van meerdere zoekresultaten, neemt de inverse en voegt vervolgens de gecombineerde resultaten samen en sorteert deze. Het
top
aantal resultaten wordt geretourneerd.Bekijk het antwoord.
{ "@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." } ] }
Omdat RRF resultaten samenvoegt, helpt het om de invoer te controleren. De volgende resultaten zijn alleen afkomstig van de volledige-tekstquery. De top twee resultaten zijn Sublieme Cliff Hotel en History Lion Resort. The Sublieme Cliff Hotel heeft een sterkere BM25 relevantie score.
{ "@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" },
In de vectorquery, die gebruikmaakt van HNSW voor het vinden van overeenkomsten, daalt het Sublieme Cliff Hotel naar de vierde positie. Historic Lion, die tweede was in de zoekopdracht in volledige tekst en derde in de vectorzoekopdracht, ondervindt niet hetzelfde fluctuatiebereik, dus het lijkt een topmatch in een gehomogeniseerde resultatenset.
"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" } ]
Semantische hybride zoekopdracht met een filter
Dit is de laatste query in de verzameling. Deze hybride query met semantische classificatie wordt gefilterd om alleen de hotels binnen een straal van 500 kilometer van Washington D.C weer te geven. U kunt instellen vectorFilterMode
op null, wat gelijk is aan de standaardwaarde (preFilter
voor nieuwere indexen en postFilter
voor oudere indexen).
Plak een POST-aanvraag om een query uit te voeren op de zoekindex. Selecteer vervolgens Aanvraag verzenden.
### Run a hybrid query POST {{baseUrl}}/indexes/hotels-vector-quickstart/docs/search?api-version=2023-11-01 HTTP/1.1 Content-Type: application/json api-key: {{apiKey}} { "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 } ] }
Bekijk het antwoord. Het antwoord is drie hotels, die worden gefilterd op locatie en gefaceteerd door
StateProvince
en semantisch opnieuw zijn gerangschikt om resultaten te promoten die het dichtst bij de zoektekenreeksquery (historic hotel walk to restaurants and shopping
) liggen.Het Old Carabelle Hotel gaat nu naar de topplaats. Zonder semantische rangschikking is Nordick's Hotel nummer één. Met semantische rangschikking herkennen de machinebegripmodellen die
historic
van toepassing zijn op "hotel, op loopafstand van dineren (restaurants) en winkelen."{ "@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" } } ] }
Belangrijke punten:
- Vectorzoekopdrachten worden opgegeven via de
vectors.value
eigenschap. Trefwoorden zoeken wordt opgegeven via desearch
eigenschap. - In een hybride zoekopdracht kunt u vectorzoekopdrachten integreren met zoeken in volledige tekst over trefwoorden. Filters, spellingcontrole en semantische classificatie zijn alleen van toepassing op tekstuele inhoud en niet op vectoren. In deze laatste query is er geen semantisch
answer
omdat het systeem er geen heeft geproduceerd die voldoende sterk was. - Werkelijke resultaten bevatten meer details, waaronder semantische onderschrift s en markeringen. De resultaten zijn gewijzigd voor leesbaarheid. Als u de volledige structuur van het antwoord wilt ophalen, voert u de aanvraag uit in de REST-client.
- Vectorzoekopdrachten worden opgegeven via de
Opschonen
Wanneer u in uw eigen abonnement werkt, is het een goed idee om aan het einde van een project te bepalen of u de gemaakte resources nog nodig hebt. Resources die actief blijven, kunnen u geld kosten. U kunt resources afzonderlijk verwijderen, maar u kunt ook de resourcegroep verwijderen als u de volledige resourceset wilt verwijderen.
U kunt resources vinden en beheren in de portal met behulp van de koppeling Alle resources of resourcegroepen in het meest linkse deelvenster.
U kunt ook deze DELETE
opdracht proberen:
### Delete an index
DELETE {{baseUrl}}/indexes/hotels-vector-quickstart?api-version=2023-11-01 HTTP/1.1
Content-Type: application/json
api-key: {{apiKey}}
Volgende stappen
Als volgende stap raden we u aan de democode voor Python, C# of JavaScript te bekijken.