빠른 시작: REST를 사용한 벡터 검색

검색 REST API를 사용하여 Azure AI 검색에서 벡터를 만들고, 로드하고, 쿼리하는 방법을 알아봅니다.

Azure AI 검색에서 벡터 저장소에는 벡터 필드와 비 벡터 필드를 정의하는 인덱스 스키마, 포함 공간을 만드는 알고리즘에 대한 벡터 구성, 쿼리 요청에 사용되는 벡터 필드 정의에 대한 설정이 있습니다. 인덱스 만들기 API는 벡터 저장소를 만듭니다.

Azure 구독이 아직 없는 경우 시작하기 전에 체험 계정을 만듭니다.

참고 항목

이 빠른 시작에서는 벡터화 단계를 생략하고 샘플 문서에 포함을 제공합니다. 자체 콘텐츠에 대해 기본 제공 데이터 청크화 및 벡터화를 추가하려면 데이터 가져오기 및 벡터화 마법사를 사용하여 엔드투엔드 연습을 시도해 보세요.

필수 조건

파일 다운로드

GitHub에서 REST 샘플을 다운로드하여 이 빠른 시작에서 요청을 보냅니다. 자세한 내용은 GitHub에서 파일 다운로드를 참조하세요.

이 문서의 지침을 사용하여 로컬 시스템에서 새 파일을 시작하고 수동으로 요청을 만들 수도 있습니다.

검색 서비스 엔드포인트 가져오기

Azure Portal에서 검색 서비스 엔드포인트를 찾을 수 있습니다.

  1. Azure Portal에 로그인하고 검색 서비스를 찾습니다.

  2. 개요 홈페이지에서 URL을 찾습니다. 엔드포인트의 예는 다음과 같습니다. https://mydemo.search.windows.net

    개요 페이지의 URL 속성 스크린샷.

이후 단계에서 이 엔드포인트를 .rest 또는 .http 파일에 붙여넣습니다.

액세스 구성

검색 엔드포인트에 대한 요청은 인증 및 권한 부여를 받아야 합니다. 이 작업에 API 키 또는 역할을 사용할 수 있습니다. 키는 시작하기가 더 쉽지만 역할이 더 안전합니다.

역할 기반 연결의 경우 다음 지침에 따라 클라이언트 앱의 ID가 아닌 사용자 ID로 Azure AI 검색에 연결합니다.

옵션 1: 키 사용

설정>를 선택한 다음, 관리자 키를 복사합니다. 관리자 키는 개체를 추가, 수정, 삭제하는 데 사용됩니다. 교환 가능한 관리자 키는 2개입니다. 둘 중 하나를 복사합니다. 자세한 내용은 키 인증을 사용하여 Azure AI 검색에 연결을 참조하세요.

Azure Portal의 API 키를 보여 주는 스크린샷.

이후 단계에서 이 키를 .rest 또는 .http 파일에 붙여넣습니다.

옵션 2: 역할 사용

검색 서비스가 역할 기반 액세스에 대해 구성되어 있는지 확인합니다. 개발자 액세스를 위한 역할 할당이 미리 구성되어 있어야 합니다. 역할 할당은 검색 인덱스를 생성, 로드 및 쿼리할 수 있는 권한을 부여해야 합니다.

이 섹션에서는 Azure CLI, Azure PowerShell 또는 Azure Portal을 사용하여 개인 ID 토큰을 가져옵니다.

  1. Azure CLI에 로그인합니다.

    az login
    
  2. 개인 ID 토큰을 가져옵니다.

    az account get-access-token --scope https://search.azure.com/.default
    

이후 단계에서 개인 ID 토큰을 .rest 또는 .http 파일에 붙여넣습니다.

참고 항목

이 섹션에서는 사용자를 대신하여 Azure AI 검색에 연결하는 로컬 클라이언트를 사용한다고 가정합니다. 애플리케이션이 Microsoft Entra ID에 등록되어 있다고 가정하고 클라이언트 앱에 대한 토큰을 가져오는 방식을 사용할 수도 있습니다.

벡터 인덱스 만들기

인덱스 만들기(REST)는 벡터 인덱스를 만들고 검색 서비스에 물리적 데이터 구조를 설정합니다.

인덱스 스키마는 호텔 콘텐츠를 중심으로 구성됩니다. 샘플 데이터는 벡터 및 비벡터 이름과 7개의 가상 호텔에 대한 설명으로 구성됩니다. 이 스키마에는 벡터 인덱싱 및 쿼리, 의미 체계 순위에 대한 구성이 포함됩니다.

  1. Visual Studio Code에서 새 텍스트 파일을 엽니다.

  2. 변수를 이전에 수집한 값으로 설정합니다. 이 예에서는 개인 ID 토큰을 사용합니다.

    @baseUrl = PUT-YOUR-SEARCH-SERVICE-URL-HERE
    @token = PUT-YOUR-PERSONAL-IDENTITY-TOKEN-HERE
    
  3. 파일을 .rest 또는 .http 파일 확장명을 사용하여 저장합니다.

  4. 다음 예제를 붙여넣어 검색 서비스에 hotels-vector-quickstart 인덱스를 만듭니다.

    ### 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" }
                        ]
                    }
                }
            ]
        }
    }
    
  5. 요청 보내기를 선택합니다. 요청을 보내려면 REST 클라이언트가 필요합니다. HTTP/1.1 201 Created 응답이 있어야 합니다. 응답 본문에는 인덱스 스키마의 JSON 표현이 포함되어야 합니다.

    주요 정보:

    • fields 컬렉션에는 텍스트 및 벡터 검색에 필요한 키 필드, 텍스트 및 벡터 필드(예: DescriptionDescriptionVector)가 포함되어 있습니다. 동일한 인덱스에 벡터 필드와 벡터가 아닌 필드를 같은 위치에 배치하면 하이브리드 쿼리가 가능해집니다. 예를 들어 필터, 의미 체계 순위를 사용하는 텍스트 검색, 벡터를 단일 쿼리 작업으로 결합할 수 있습니다.
    • 벡터 필드는 dimensionsvectorSearchProfile 속성이 있는 type: Collection(Edm.Single)이어야 합니다.
    • vectorSearch 섹션은 근사 가장 인접한 항목 알고리즘 구성 및 프로필의 배열입니다. 지원되는 알고리즘에는 HNSW(Hierarchical Navigable Small World)와 철저한 k-가장 인접한 항목이 포함됩니다. 자세한 내용은 벡터 검색의 관련성 점수를 참조하세요.
    • [선택 사항]: semantic 구성을 사용하면 검색 결과의 순위 지정을 다시 지정할 수 있습니다. 구성에 지정된 문자열 필드에 대한 semantic 형식의 쿼리에서 결과 순위를 다시 지정할 수 있습니다. 자세한 내용은 의미 체계 순위 지정 개요를 참조하세요.

문서 업로드

인덱스 만들기 및 로드는 별도의 단계입니다. Azure AI 검색에서 인덱스에는 검색 가능한 모든 데이터가 포함되어 있으며 검색 서비스에서 실행되는 쿼리가 있습니다. REST 호출의 경우 데이터는 JSON 문서로 제공됩니다. 이 작업에는 문서- 인덱스 REST API를 사용합니다.

docs 컬렉션 및 index 작업을 포함하도록 URI가 길어집니다.

Important

다음 예는 실행할 수 없는 코드입니다. 각각 1,536개의 포함이 있으므로 이 문서에 추가하기에는 너무 길어 가독성을 위해 벡트 값을 제외했습니다. 이 단계를 시도하려면 GitHub의 샘플에서 실행 가능한 코드를 복사하세요.

### 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"
            ]
        }
    ]
}

주요 정보:

  • 페이로드의 문서는 인덱스 스키마에 정의된 필드로 구성됩니다.
  • 벡터 필드에는 부동 소수점 값이 포함되어 있습니다. 차원 특성에는 각각 최소 2개, 최대 3,072개의 부동 소수점 값이 있습니다. 이 빠른 시작에서는 차원 특성을 1,536으로 설정합니다. 이 값이 Azure OpenAI의 text-embedding-ada-002 모델에서 생성된 포함 크기이기 때문입니다.

쿼리 실행

이제 문서가 로드되었으므로 문서 - 게시물 검색(REST)을 사용하여 문서에 대한 벡터 쿼리를 실행할 수 있습니다.

다양한 패턴을 보여 주는 몇 가지 쿼리가 있습니다.

이 섹션의 벡터 쿼리는 다음 두 문자열을 기반으로 합니다.

  • 검색 문자열: historic hotel walk to restaurants and shopping
  • 벡터 쿼리 문자열(수학적 표현으로 벡터화): classic lodging near running trails, eateries, retail

벡터 쿼리 문자열은 검색 문자열과 의미 체계상 유사하지만 검색 인덱스에 존재하지 않는 용어를 포함합니다. classic lodging near running trails, eateries, retail에 대한 키워드 검색을 수행하면 결과는 0입니다. 이 예를 사용하여 일치하는 용어가 없더라도 관련 결과를 가져올 수 있는 방법을 보여 줍니다.

Important

다음 예는 실행할 수 없는 코드입니다. 각 배열에 1,536개의 포함이 있으므로 이 문서에 추가하기에는 너무 길어 가독성을 위해 벡트 값을 제외했습니다. 이 쿼리를 사용해 보려면 GitHub의 샘플에서 실행 가능한 코드를 복사하세요.

  1. POST 요청에 붙여넣어 검색 인덱스를 쿼리합니다. 그런 다음, 요청 보내기를 선택합니다. /docs/search 연산자를 포함하도록 URI가 길어집니다.

    ### 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
                }
            ]
        }
    

    이 벡터 쿼리는 간결성을 위해 단축되었습니다. vectorQueries.vector는 쿼리 입력의 벡터화된 텍스트를 포함하고, fields는 검색할 벡터 필드를 결정하고, k는 반환할 가장 인접한 항목의 수를 지정합니다.

    벡터 쿼리 문자열은 classic lodging near running trails, eateries, retail이며, 이 쿼리에서 1,536개의 포함으로 벡터화됩니다.

  2. 응답을 검토합니다. classic lodging near running trails, eateries, retail에 해당하는 벡터에 대한 응답에는 7개의 결과가 포함됩니다. 각 결과는 검색 점수와 select에 나열된 필드를 제공합니다. 유사성 검색에서 응답에는 항상 유사성 점수 값을 기준으로 순서가 지정된 k개의 결과가 포함됩니다.

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

필터를 사용한 단일 벡터 검색

필터를 추가할 수 있지만 필터는 인덱스의 벡터가 아닌 콘텐츠에 적용됩니다. 이 예에서는 필터가 Tags 필드에 적용되어 무료 Wi-Fi를 제공하지 않는 호텔을 필터링합니다.

  1. POST 요청에 붙여넣어 검색 인덱스를 쿼리합니다.

    ### 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
            },
        ]
    }
    
  2. 응답을 검토합니다. 쿼리는 이전 예와 동일하지만 후처리 제외 필터를 포함하고 있으며 무료 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"
                ]
            }
        ]
    }
    

하이브리드 검색은 단일 검색 요청의 키워드 쿼리와 벡터 쿼리로 구성됩니다. 이 예에서는 벡터 쿼리와 전체 텍스트 검색을 동시에 실행합니다.

  • 검색 문자열: historic hotel walk to restaurants and shopping
  • 벡터 쿼리 문자열(수학적 표현으로 벡터화): classic lodging near running trails, eateries, retail
  1. POST 요청에 붙여넣어 검색 인덱스를 쿼리합니다. 그런 다음, 요청 보내기를 선택합니다.

    ### 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
            }
        ]
    }
    

    하이브리드 쿼리이므로 결과는 RRF(Reciprocal Rank Fusion)에 따라 순위가 매겨집니다. RRF는 여러 검색 결과의 검색 점수를 평가하고 그 반대를 취한 다음 결합된 결과를 병합하고 정렬합니다. top개의 결과가 반환됩니다.

  2. 응답을 검토합니다.

    {
        "@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는 결과를 병합하므로 입력을 검토하는 데 도움이 됩니다. 다음은 전체 텍스트 쿼리에서만 나온 결과입니다. 상위 2개 결과는 Sublime Cliff Hotel과 History Lion Resort입니다. Sublime Cliff Hotel은 BM25 관련성 점수가 더 높습니다.

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

    HNSW를 사용하여 일치 항목을 찾는 벡터 전용 쿼리에서 Sublime Cliff Hotel은 네 번째 순위로 떨어집니다. 전체 텍스트 검색에서 2위, 벡터 검색에서 3위를 차지했던 Historic Lion은 동일한 변동 범위를 가지지 않으므로 균질화된 결과 집합에서 상위 일치 항목으로 표시됩니다.

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

필터를 사용한 의미 체계 하이브리드 검색

컬렉션의 마지막 쿼리는 다음과 같습니다. 의미 체계 순위를 사용하는 이 하이브리드 쿼리는 워싱턴 D.C.에서 반경 500km 내에 있는 호텔만 표시하도록 필터링되었습니다. vectorFilterMode를 null로 설정할 수 있습니다. 이는 기본값(최신 인덱스의 경우 preFilter, 이전 인덱스의 경우 postFilter)과 동일합니다.

  1. POST 요청에 붙여넣어 검색 인덱스를 쿼리합니다. 그런 다음, 요청 보내기를 선택합니다.

    ### 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
            }
        ]
    }
    
  2. 응답을 검토합니다. 응답은 호텔 세 곳으로, 위치별로 필터링되고 StateProvince로 패싯 처리되며 의미 체계 순위가 다시 지정되어 검색 문자열 쿼리(historic hotel walk to restaurants and shopping)에 가장 가까운 결과를 승격시킵니다.

    이제 Old Carabelle Hotel이 1위가 되었습니다. 의미 체계 순위 지정이 없으면 Nordick's Hotel이 1위입니다. 의미 체계 순위 지정을 통해 기계 독해 모델은 historic이 "식사(식당) 및 쇼핑 위치가 도보 거리 내에 있는 호텔"에 적용된다는 것을 인식합니다.

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

    주요 정보:

    • 벡터 검색은 vectors.value 속성을 통해 지정됩니다. 키워드 검색은 search 속성을 통해 지정됩니다.
    • 하이브리드 검색에서는 키워드에 대한 전체 텍스트 검색과 벡터 검색을 통합할 수 있습니다. 필터, 맞춤법 검사 및 의미 체계 순위 지정은 텍스트 콘텐츠에만 적용되며 벡터에는 적용되지 않습니다. 이 마지막 쿼리에는 시스템이 충분히 강력한 쿼리를 생성하지 않았기 때문에 의미 체계 answer가 없습니다.
    • 실제 결과에는 의미 체계 캡션 및 강조 표시를 포함한 더 자세한 내용이 포함됩니다. 가독성을 위해 결과가 수정되었습니다. 응답의 전체 구조를 확인하려면 REST 클라이언트에서 요청을 실행하세요.

정리

본인 소유의 구독으로 이 모듈을 진행하고 있는 경우에는 프로젝트가 끝날 때 여기에서 만든 리소스가 계속 필요한지 확인하는 것이 좋습니다. 계속 실행되는 리소스에는 요금이 부과될 수 있습니다. 리소스를 개별적으로 삭제하거나 리소스 그룹을 삭제하여 전체 리소스 세트를 삭제할 수 있습니다.

가장 왼쪽 창의 모든 리소스 또는 리소스 그룹 링크를 사용하여 포털에서 리소스를 찾고 관리할 수 있습니다.

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}}

다음 단계

다음 단계로 Python, C# 또는 JavaScript의 데모 코드를 살펴보는 것이 좋습니다.