Elasticsearch has been a widely used search engine that can handle a variety of complex search tasks. With the introduction of vector search, Elasticsearch's capabilities have extended even further into the realm of machine learning and artificial intelligence. Specifically on Alibaba Cloud, the aliyun-knn plugin utilizes the vector library of Proxima, a vector search engine developed by Alibaba DAMO Academy, to enhance search functionalities.
In this article, we will delve into how to harness the power of the aliyun-knn plugin within Alibaba Cloud Elasticsearch, and demonstrate its use in scenarios such as image search, video fingerprinting, and recommendation systems. For more information on Alibaba Cloud Elasticsearch, visit the official product page
The Alibaba Cloud Elasticsearch vector search engine, empowered by the aliyun-knn plugin, is already leveraged in many production scenarios within Alibaba Group. It's built to handle complex tasks including Pailitao image search, Youku video fingerprinting, and Taobao commodity recommendations. Additionally, it supports features characteristic of distributed searches like multiple replica shards and restoration.
Before we delve into the code, ensure that the aliyun-knn plugin is installed on your Elasticsearch cluster. The plugin’s availability by default is contingent on your cluster’s version and kernel version. You can verify this by running GET _cat/plugins?v in your Elasticsearch console.
For clusters running a kernel version earlier than V1.2.0, follow the instructions provided in Install and remove a built-in plug-in
For more advanced features, you may need a cluster with a kernel version V1.3.0 or later. Data migration using snapshots in OSS or DataWorks is not supported, and Logstash is recommended as an alternative.
Let’s create a basic vector index on an Alibaba Cloud Elasticsearch cluster using the Kibana console.
PUT /my_vector_index
{
"settings": {
"index.codec": "proxima",
"index.vector.algorithm": "hnsw"
},
"mappings": {
"properties": {
"feature": {
"type": "proxima_vector",
"dim": 128,
"vector_type": "float",
"distance_method": "SquaredEuclidean"
}
}
}
}
In this example, we're creating a Proxima vector index with Euclidean distance as the distance measurement metric.
Once the index is created, you can add a document to it. Here we are adding a two-dimensional float-type vector.
POST /my_vector_index/_doc
{
"feature": [1.0, 2.0]
}
Replace the array [1.0, 2.0] with the actual data you wish to index.
Here’s how you can perform a standard search with the aliyun-knn plugin:
GET /my_vector_index/_search
{
"query": {
"hnsw": {
"feature": {
"vector": [1.5, 2.5],
"size": 10
}
}
}
}
The size parameter defines how many matching vector documents to retrieve.
Using Alibaba Cloud Elasticsearch with the aliyun-knn plugin offers a fantastic opportunity to boost your search capabilities with the power of AI, especially in scenarios demanding vector-based search operations.
Interested in trying it out? Alibaba Cloud Elasticsearch offers a 30 Day Free Trial to help you get started on your search journey. Ready to start your journey with Elasticsearch on Alibaba Cloud? Explore our tailored Cloud solutions and services to take the first step towards transforming your data into a visual masterpiece.
Enhance Text Analysis: Mastering the Analysis-IK Plugin for Elasticsearch
A Step-By-Step Guide on Using Alibaba Cloud Elasticsearch's Analytic-Search Plugin
Data Geek - April 29, 2024
Alibaba Clouder - December 30, 2020
Data Geek - April 12, 2024
Data Geek - April 11, 2024
Data Geek - April 18, 2024
Data Geek - August 7, 2024
Alibaba Cloud Elasticsearch helps users easy to build AI-powered search applications seamlessly integrated with large language models, and featuring for the enterprise: robust access control, security monitoring, and automatic updates.
Learn MoreOpenSearch helps develop intelligent search services.
Learn MoreAn intelligent image search service with product search and generic search features to help users resolve image search requests.
Learn MoreMore Posts by Data Geek