Share via


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

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

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

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

참고 항목

안정적인 2023-11-01 REST API 버전은 데이터 청크 및 포함을 위한 외부 솔루션에 따라 달라집니다. 기본 제공 데이터 청크 및 벡터화(공개 미리 보기) 기능을 평가하려면 엔드투엔드 연습을 위해 데이터 가져오기 및 벡터화 마법사를 사용해 보세요.

필수 조건

  • REST 클라이언트가 있는 Visual Studio Code입니다. 시작에 도움이 필요한 경우 빠른 시작: REST를 사용한 텍스트 검색을 참조하세요.

  • Azure AI Search는 모든 지역 및 모든 계층에 있습니다. 이 빠른 시작에서는 무료 계층을 사용할 수 있지만 더 큰 데이터 파일에는 기본 이상을 사용하는 것이 좋습니다. 현재 구독에서 기존 Azure AI 검색 리소스를 만들거나찾습니다.

    대부분의 기존 서비스는 벡터 검색을 지원합니다. 2019년 1월 이전에 만든 서비스의 작은 하위 집합의 경우 벡터 필드가 포함된 인덱스를 만들 때 실패합니다. 이 경우에는 새 서비스를 만들어야 합니다.

  • 필요에 따라 의미 체계 재전송을 호출 하는 쿼리 예제를 실행하려면 검색 서비스가 기본 계층 이상이어야 하며 의미 체계 순위가 활성화되어 있어야 합니다.

  • 필요에 따라 배포text-embedding-ada-002가 있는 Azure OpenAI 리소스입니다. 원본 .rest 파일에는 새 텍스트 포함을 생성하기 위한 선택적 단계가 포함되어 있지만 이 종속성을 생략할 수 있도록 미리 생성된 포함을 제공합니다.

파일 다운로드

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

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

검색 서비스 키 및 URL 복사

REST 호출에는 모든 요청에 대한 검색 서비스 엔드포인트 및 API 키가 필요합니다. Azure Portal에서 이러한 값을 가져올 수 있습니다.

  1. Azure Portal에 로그인합니다. 개요 페이지로 이동하여 URL을 복사합니다. 엔드포인트의 예는 다음과 같습니다. https://mydemo.search.windows.net

  2. 설정> 키를 선택하고 관리 키를 복사합니다. 관리자 키는 개체를 추가, 수정, 삭제하는 데 사용됩니다. 교환 가능한 관리자 키는 2개입니다. 둘 중 하나를 복사합니다.

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

벡터 인덱스 만들기

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

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

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

  2. 변수를 이전에 수집한 검색 엔드포인트 및 API 키로 설정합니다.

    @baseUrl = PUT-YOUR-SEARCH-SERVICE-URL-HERE
    @apiKey = PUT-YOUR-ADMIN-API-KEY-HERE
    
  3. 파일 확장자를 사용하여 .rest 파일을 저장합니다.

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

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

    주요 정보:

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

문서 업로드

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

컬렉션 및 작업을 포함 docs 하도록 URI가 확장됩니다 index .

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

주요 정보:

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

쿼리 실행

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

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

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

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

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

Important

다음 예제는 실행할 수 없는 코드입니다. 가독성을 위해 각 배열에 1,536개의 포함 항목이 포함되어 있으므로 이 문서에 비해 너무 길어서 벡터 값을 제외했습니다. 이러한 쿼리를 시도하려면 GitHub샘플에서 실행 가능한 코드를 복사합니다.

  1. POST 요청에 붙여넣어 검색 인덱스 쿼리 그런 다음, 요청 보내기를 선택합니다. 연산자를 포함하도록 URI가 확장됩니다 /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
        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
                }
            ]
        }
    

    이 벡터 쿼리는 간결하게 단축됩니다. 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
        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
            },
        ]
    }
    
  2. 응답을 검토합니다. 쿼리는 이전 예제와 동일하지만 사후 처리 제외 필터를 포함하고 무료 Wi-Fi가 있는 3개의 호텔만 반환합니다.

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

    하이브리드 쿼리이므로 결과는 RRF(상호 순위 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개 결과는 숭고한 클리프 호텔과 히스토리 라이온 리조트입니다. 숭고한 클리프 호텔은 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위를 차지했던 기록 사자는 변동 범위가 동일하지 않으므로 균질화된 결과 집합에서 상위 일치 항목으로 표시됩니다.

        "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 내에 있는 호텔만 표시하도록 필터링됩니다. null로 설정할 vectorFilterMode 수 있습니다. 이는 기본값과 동일합니다(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
        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
            }
        ]
    }
    
  2. 응답을 검토합니다. 응답은 위치별로 필터링되고 검색 문자열 쿼리(historic hotel walk to restaurants and shopping)에 가장 가까운 결과를 승격하기 위해 패싯 StateProvince 으로 패싯되고 의미상 재전송되는 세 개의 호텔입니다.

    올드 카라벨 호텔은 이제 최고의 자리로 이동합니다. 의미 체계 순위 지정이 없으면 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 지정됩니다.
    • 하이브리드 검색에서는 키워드(keyword) 전체 텍스트 검색과 벡터 검색을 통합할 수 있습니다. 필터, 맞춤법 검사 및 의미 체계 순위 지정은 텍스트 콘텐츠에만 적용되며 벡터에는 적용되지 않습니다. 이 마지막 쿼리에는 시스템이 충분히 강력한 쿼리를 생성하지 않았기 때문에 의미 체계 answer가 없습니다.
    • 실제 결과에는 의미 체계 캡션 및 강조 표시를 포함한 더 자세한 내용이 포함됩니다. 가독성을 위해 결과가 수정되었습니다. 응답의 전체 구조를 가져오려면 REST 클라이언트에서 요청을 실행합니다.

정리

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

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

다음 DELETE 명령을 사용해 볼 수도 있습니다.

### Delete an index
DELETE  {{baseUrl}}/indexes/hotels-vector-quickstart?api-version=2023-11-01 HTTP/1.1
    Content-Type: application/json
    api-key: {{apiKey}}

다음 단계

다음 단계로 Python, C#또는 JavaScript에 대한 데모 코드를 검토하는 것이 좋습니다.