التشغيل السريع: البحث عن المتجهات باستخدام REST

تعرف على كيفية استخدام واجهات برمجة تطبيقات Search REST لإنشاء ناقلات البيانات وتحميلها والاستعلام فيها في Azure الذكاء الاصطناعي Search.

في Azure الذكاء الاصطناعي Search، يحتوي مخزن المتجهات على مخطط فهرس يحدد الحقول المتجهة وغير الوسيطة، وتكوين متجه للخوارزميات التي تنشئ مساحة التضمين، وإعدادات على تعريفات حقول المتجهات المستخدمة في طلبات الاستعلام. تنشئ واجهة برمجة تطبيقات Create Index مخزن المتجهات.

في حال لم يكن لديك اشتراك Azure، فأنشئ حساباً مجانيّاً قبل البدء.

إشعار

يعتمد إصدار REST API المستقر 2023-11-01 على الحلول الخارجية لتقسيم البيانات وتضمينها. إذا كنت ترغب في تقييم ميزات تجميع البيانات المضمنة وميزات المتجهات (معاينة عامة)، فجرب معالج استيراد البيانات واتجاهها لمعاينة شاملة.

المتطلبات الأساسية

  • Visual Studio Code مع عميل REST. إذا كنت بحاجة إلى مساعدة في بدء الاستخدام، فشاهد التشغيل السريع: البحث عن النص باستخدام REST.

  • Azure الذكاء الاصطناعي Search، في أي منطقة وعلى أي مستوى. يمكنك استخدام المستوى المجاني لبدء التشغيل السريع هذا، ولكن يوصى باستخدام Basic أو أعلى لملفات البيانات الأكبر حجما. إنشاء مورد Azure الذكاء الاصطناعي Search موجود أو العثور عليه ضمن اشتراكك الحالي.

    تدعم معظم الخدمات الموجودة البحث عن المتجهات. بالنسبة لمجموعة فرعية صغيرة من الخدمات التي تم إنشاؤها قبل يناير 2019، يفشل الفهرس الذي يحتوي على حقول المتجهات عند الإنشاء. في هذه الحالة، يجب إنشاء خدمة جديدة.

  • بشكل اختياري، لتشغيل مثال الاستعلام الذي يستدعي إعادة الترحيل الدلالي، يجب أن تكون خدمة البحث الخاصة بك هي المستوى الأساسي أو الأعلى، مع تمكين الترتيب الدلالي.

  • اختياريا، مورد Azure OpenAI مع توزيع .text-embedding-ada-002 يتضمن الملف المصدر .rest خطوة اختيارية لإنشاء تضمينات نصية جديدة، ولكننا نوفر عمليات تضمين تم إنشاؤها مسبقا بحيث يمكنك حذف هذه التبعية.

تحميل الملفات

قم بتنزيل نموذج REST من GitHub لإرسال الطلبات في هذا التشغيل السريع. لمزيد من المعلومات، راجع تنزيل الملفات من GitHub.

يمكنك أيضا بدء تشغيل ملف جديد على النظام المحلي وإنشاء الطلبات يدويا باستخدام الإرشادات الواردة في هذه المقالة.

نسخ مفتاح خدمة البحث وعنوان URL

تتطلب استدعاءات REST نقطة نهاية خدمة البحث ومفتاح API في كل طلب. يمكنك الحصول على هذه القيم من مدخل Microsoft Azure.

  1. قم بتسجيل الدخول إلى بوابة Azure. انتقل إلى صفحة نظرة عامة وانسخ عنوان URL. قد يبدو مثال نقطة النهاية بالشكل https://mydemo.search.windows.net.

  2. حدد الإعدادات> Keys وانسخ مفتاح مسؤول. يتم استخدام مفاتيح مسؤول لإضافة الكائنات وتعديلها وحذفها. هناك مفتاحان للمسؤول قابلان للتبديل. انسخ أي منهما.

    لقطة شاشة تعرض مفاتيح URL وواجهة برمجة التطبيقات في مدخل Microsoft Azure.

إنشاء فهرس متجه

ينشئ Create Index (REST) فهرسا متجها وينشئ بنيات البيانات الفعلية على خدمة البحث.

يتم تنظيم مخطط الفهرس حول محتوى الفندق. تتكون بيانات العينة من أسماء متجهات وغير عوامل ووصف لسبعة فنادق وهمية. يتضمن هذا المخطط تكوينات لفهرسة المتجهات والاستعلامات، وللترتيب الدلالي.

  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 تتضمن المجموعة حقل مفتاح مطلوب وحقول نص ومتجه (مثل Description وDescriptionVector) للبحث في النص والمتجه. يتيح تجميع الحقول المتجهة وغير الخاصة في نفس الفهرس الاستعلامات المختلطة. على سبيل المثال، يمكنك دمج عوامل التصفية والبحث عن النص مع الترتيب الدلالي والمتجهات في عملية استعلام واحدة.
    • يجب أن تكون type: Collection(Edm.Single) حقول المتجهات مع dimensions خصائص و vectorSearchProfile .
    • القسم vectorSearch عبارة عن صفيف من أقرب تكوينات خوارزمية جارة وملفات تعريف تقريبية. تتضمن الخوارزميات المدعومة عالما صغيرا هرميا قابلا للتنقل وجار شامل من أقرب جيران K. لمزيد من المعلومات، راجع تسجيل الصلة في البحث عن المتجهات.
    • [اختياري]: semantic يتيح التكوين إعادة نسخ نتائج البحث. يمكنك إعادة تجميع النتائج في استعلامات من نوع semantic لحقول السلسلة المحددة في التكوين. لمعرفة المزيد، راجع نظرة عامة على الترتيب الدلالي.

تحميل المستندات

يعد إنشاء الفهرس وتحميله خطوات منفصلة. في Azure الذكاء الاصطناعي Search، يحتوي الفهرس على جميع البيانات والاستعلامات القابلة للبحث التي يتم تشغيلها على خدمة البحث. بالنسبة لمكالمات REST، يتم توفير البيانات كمستندات JSON. استخدام Documents- Index REST API لهذه المهمة.

تم توسيع URI ليشمل docs المجموعة والعملية index .

هام

المثال التالي ليس تعليمة برمجية قابلة للتشغيل. لقابلية القراءة، استبعدنا قيم المتجهات لأن كل واحد يحتوي على 1536 تضمينا، وهو طويل جدا لهذه المقالة. إذا كنت ترغب في تجربة هذه الخطوة، انسخ التعليمات البرمجية القابلة للتشغيل من النموذج على 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 كحد أدنى و3072 قيمة للنقطة العائمة كحد أقصى لكل منها. يعين هذا التشغيل السريع سمة الأبعاد إلى 1536 لأن هذا هو حجم التضمينات التي تم إنشاؤها بواسطة نموذج Open الذكاء الاصطناعي's 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كلمة أساسية، تكون النتائج صفرا. نستخدم هذا المثال لإظهار كيفية الحصول على نتائج ذات صلة حتى إذا لم تكن هناك مصطلحات مطابقة.

هام

الأمثلة التالية ليست تعليمات برمجية قابلة للتشغيل. لقابلية القراءة، استبعدنا قيم المتجهات لأن كل صفيف يحتوي على 1536 تضمينا، وهو طويل جدا لهذه المقالة. إذا كنت ترغب في تجربة هذه الاستعلامات، انسخ التعليمات البرمجية القابلة للتشغيل من النموذج على 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، والتي يتم تحويلها إلى 1536 تضمينا لهذا الاستعلام.

  2. راجع الاستجابة. تتضمن الاستجابة لمكافئ classic lodging near running trails, eateries, retail المتجه سبع نتائج. توفر كل نتيجة درجة بحث والحقول المدرجة في 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 مجانية.

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

    نظرا لأن هذا استعلام مختلط، يتم تصنيف النتائج حسب Fusion Rank Fusion (RRF). يقيم 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 يدمج النتائج، فإنه يساعد على مراجعة المدخلات. النتائج التالية من استعلام النص الكامل فقط. أفضل نتيجتين هما فندق Sublime Cliff وS history Lion Resort. يتمتع فندق Sublime Cliff بنقاط اتصال 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 إلى الموضع الرابع. لا يواجه 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"
            }
        ]
    

البحث المختلط الدلالي باستخدام عامل تصفية

إليك آخر استعلام في المجموعة. تمت تصفية هذا الاستعلام المختلط ذو الترتيب الدلالي لإظهار الفنادق فقط ضمن دائرة نصف قطرها 500 كيلومتر في واشنطن العاصمة. يمكنك تعيين 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
        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. راجع الاستجابة. الاستجابة هي ثلاثة فنادق، والتي تتم تصفيتها حسب الموقع وواجهاتها وإعادة ترتيبها StateProvince دلاليا لتعزيز النتائج الأقرب إلى استعلام سلسلة البحث (historic hotel walk to restaurants and shopping).

    ينتقل فندق Old Carabelle الآن إلى أعلى مكان. بدون ترتيب دلالي، يعتبر فندق نورك رقم واحد. مع الترتيب الدلالي، تدرك نماذج فهم الآلة أن 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.

تنظيف

عندما تعمل على اشتراكك الخاص، من الأفضل أن تُحدد في نهاية المشروع ما إذا كنت لا تزال بحاجة إلى الموارد التي أنشأتها أو لا. الموارد المتبقية قيد التشغيل يمكن أن تكلفك المال. يمكنك حذف الموارد بشكل فردي أو حذف مجموعة الموارد لحذف تشكيلة الموارد بأكملها.

يمكنك العثور على الموارد وإدارتها في المدخل باستخدام الارتباط All resources أو Resource groups في الجزء الموجود في أقصى اليسار.

يمكنك أيضا تجربة هذا 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.