- Elasticsearch Guide: other versions:
- What’s new in 8.17
- Elasticsearch basics
- Quick starts
- Set up Elasticsearch
- Run Elasticsearch locally
- Installing Elasticsearch
- Configuring Elasticsearch
- Important Elasticsearch configuration
- Secure settings
- Auditing settings
- Circuit breaker settings
- Cluster-level shard allocation and routing settings
- Miscellaneous cluster settings
- Cross-cluster replication settings
- Discovery and cluster formation settings
- Data stream lifecycle settings
- Field data cache settings
- Local gateway settings
- Health Diagnostic settings
- Index lifecycle management settings
- Index management settings
- Index recovery settings
- Indexing buffer settings
- Inference settings
- License settings
- Machine learning settings
- Monitoring settings
- Node settings
- Networking
- Node query cache settings
- Path settings
- Search settings
- Security settings
- Shard request cache settings
- Snapshot and restore settings
- Transforms settings
- Thread pools
- Watcher settings
- Set JVM options
- Important system configuration
- Bootstrap Checks
- Heap size check
- File descriptor check
- Memory lock check
- Maximum number of threads check
- Max file size check
- Maximum size virtual memory check
- Maximum map count check
- Client JVM check
- Use serial collector check
- System call filter check
- OnError and OnOutOfMemoryError checks
- Early-access check
- All permission check
- Discovery configuration check
- Bootstrap Checks for X-Pack
- Starting Elasticsearch
- Stopping Elasticsearch
- Discovery and cluster formation
- Add and remove nodes in your cluster
- Full-cluster restart and rolling restart
- Remote clusters
- Plugins
- Upgrade Elasticsearch
- Index modules
- Mapping
- Dynamic mapping
- Explicit mapping
- Runtime fields
- Field data types
- Aggregate metric
- Alias
- Arrays
- Binary
- Boolean
- Completion
- Date
- Date nanoseconds
- Dense vector
- Flattened
- Geopoint
- Geoshape
- Histogram
- IP
- Join
- Keyword
- Nested
- Numeric
- Object
- Pass-through object
- Percolator
- Point
- Range
- Rank feature
- Rank features
- Search-as-you-type
- Semantic text
- Shape
- Sparse vector
- Text
- Token count
- Unsigned long
- Version
- Metadata fields
- Mapping parameters
analyzer
coerce
copy_to
doc_values
dynamic
eager_global_ordinals
enabled
format
ignore_above
index.mapping.ignore_above
ignore_malformed
index
index_options
index_phrases
index_prefixes
meta
fields
normalizer
norms
null_value
position_increment_gap
properties
search_analyzer
similarity
store
subobjects
term_vector
- Mapping limit settings
- Removal of mapping types
- Text analysis
- Overview
- Concepts
- Configure text analysis
- Built-in analyzer reference
- Tokenizer reference
- Token filter reference
- Apostrophe
- ASCII folding
- CJK bigram
- CJK width
- Classic
- Common grams
- Conditional
- Decimal digit
- Delimited payload
- Dictionary decompounder
- Edge n-gram
- Elision
- Fingerprint
- Flatten graph
- Hunspell
- Hyphenation decompounder
- Keep types
- Keep words
- Keyword marker
- Keyword repeat
- KStem
- Length
- Limit token count
- Lowercase
- MinHash
- Multiplexer
- N-gram
- Normalization
- Pattern capture
- Pattern replace
- Phonetic
- Porter stem
- Predicate script
- Remove duplicates
- Reverse
- Shingle
- Snowball
- Stemmer
- Stemmer override
- Stop
- Synonym
- Synonym graph
- Trim
- Truncate
- Unique
- Uppercase
- Word delimiter
- Word delimiter graph
- Character filters reference
- Normalizers
- Index templates
- Data streams
- Ingest pipelines
- Example: Parse logs
- Enrich your data
- Processor reference
- Append
- Attachment
- Bytes
- Circle
- Community ID
- Convert
- CSV
- Date
- Date index name
- Dissect
- Dot expander
- Drop
- Enrich
- Fail
- Fingerprint
- Foreach
- Geo-grid
- GeoIP
- Grok
- Gsub
- HTML strip
- Inference
- IP Location
- Join
- JSON
- KV
- Lowercase
- Network direction
- Pipeline
- Redact
- Registered domain
- Remove
- Rename
- Reroute
- Script
- Set
- Set security user
- Sort
- Split
- Terminate
- Trim
- Uppercase
- URL decode
- URI parts
- User agent
- Ingest pipelines in Search
- Aliases
- Search your data
- The search API
- Sort search results
- Paginate search results
- Retrieve selected fields
- Search multiple data streams and indices using a query
- Collapse search results
- Filter search results
- Highlighting
- Long-running searches
- Near real-time search
- Retrieve inner hits
- Search shard routing
- Searching with query rules
- Search templates
- Full-text search
- Search relevance optimizations
- Retrievers
- kNN search
- Semantic search
- Retrieval augmented generation
- Search across clusters
- Search with synonyms
- Search Applications
- Search analytics
- The search API
- Re-ranking
- Query DSL
- Aggregations
- Bucket aggregations
- Adjacency matrix
- Auto-interval date histogram
- Categorize text
- Children
- Composite
- Date histogram
- Date range
- Diversified sampler
- Filter
- Filters
- Frequent item sets
- Geo-distance
- Geohash grid
- Geohex grid
- Geotile grid
- Global
- Histogram
- IP prefix
- IP range
- Missing
- Multi Terms
- Nested
- Parent
- Random sampler
- Range
- Rare terms
- Reverse nested
- Sampler
- Significant terms
- Significant text
- Terms
- Time series
- Variable width histogram
- Subtleties of bucketing range fields
- Metrics aggregations
- Pipeline aggregations
- Average bucket
- Bucket script
- Bucket count K-S test
- Bucket correlation
- Bucket selector
- Bucket sort
- Change point
- Cumulative cardinality
- Cumulative sum
- Derivative
- Extended stats bucket
- Inference bucket
- Max bucket
- Min bucket
- Moving function
- Moving percentiles
- Normalize
- Percentiles bucket
- Serial differencing
- Stats bucket
- Sum bucket
- Bucket aggregations
- Geospatial analysis
- Connectors
- EQL
- ES|QL
- SQL
- Overview
- Getting Started with SQL
- Conventions and Terminology
- Security
- SQL REST API
- SQL Translate API
- SQL CLI
- SQL JDBC
- SQL ODBC
- SQL Client Applications
- SQL Language
- Functions and Operators
- Comparison Operators
- Logical Operators
- Math Operators
- Cast Operators
- LIKE and RLIKE Operators
- Aggregate Functions
- Grouping Functions
- Date/Time and Interval Functions and Operators
- Full-Text Search Functions
- Mathematical Functions
- String Functions
- Type Conversion Functions
- Geo Functions
- Conditional Functions And Expressions
- System Functions
- Reserved keywords
- SQL Limitations
- Scripting
- Data management
- ILM: Manage the index lifecycle
- Tutorial: Customize built-in policies
- Tutorial: Automate rollover
- Index management in Kibana
- Overview
- Concepts
- Index lifecycle actions
- Configure a lifecycle policy
- Migrate index allocation filters to node roles
- Troubleshooting index lifecycle management errors
- Start and stop index lifecycle management
- Manage existing indices
- Skip rollover
- Restore a managed data stream or index
- Data tiers
- Autoscaling
- Monitor a cluster
- Roll up or transform your data
- Set up a cluster for high availability
- Snapshot and restore
- Secure the Elastic Stack
- Elasticsearch security principles
- Start the Elastic Stack with security enabled automatically
- Manually configure security
- Updating node security certificates
- User authentication
- Built-in users
- Service accounts
- Internal users
- Token-based authentication services
- User profiles
- Realms
- Realm chains
- Security domains
- Active Directory user authentication
- File-based user authentication
- LDAP user authentication
- Native user authentication
- OpenID Connect authentication
- PKI user authentication
- SAML authentication
- Kerberos authentication
- JWT authentication
- Integrating with other authentication systems
- Enabling anonymous access
- Looking up users without authentication
- Controlling the user cache
- Configuring SAML single-sign-on on the Elastic Stack
- Configuring single sign-on to the Elastic Stack using OpenID Connect
- User authorization
- Built-in roles
- Defining roles
- Role restriction
- Security privileges
- Document level security
- Field level security
- Granting privileges for data streams and aliases
- Mapping users and groups to roles
- Setting up field and document level security
- Submitting requests on behalf of other users
- Configuring authorization delegation
- Customizing roles and authorization
- Enable audit logging
- Restricting connections with IP filtering
- Securing clients and integrations
- Operator privileges
- Troubleshooting
- Some settings are not returned via the nodes settings API
- Authorization exceptions
- Users command fails due to extra arguments
- Users are frequently locked out of Active Directory
- Certificate verification fails for curl on Mac
- SSLHandshakeException causes connections to fail
- Common SSL/TLS exceptions
- Common Kerberos exceptions
- Common SAML issues
- Internal Server Error in Kibana
- Setup-passwords command fails due to connection failure
- Failures due to relocation of the configuration files
- Limitations
- Watcher
- Cross-cluster replication
- Data store architecture
- REST APIs
- API conventions
- Common options
- REST API compatibility
- Autoscaling APIs
- Behavioral Analytics APIs
- Compact and aligned text (CAT) APIs
- cat aliases
- cat allocation
- cat anomaly detectors
- cat component templates
- cat count
- cat data frame analytics
- cat datafeeds
- cat fielddata
- cat health
- cat indices
- cat master
- cat nodeattrs
- cat nodes
- cat pending tasks
- cat plugins
- cat recovery
- cat repositories
- cat segments
- cat shards
- cat snapshots
- cat task management
- cat templates
- cat thread pool
- cat trained model
- cat transforms
- Cluster APIs
- Cluster allocation explain
- Cluster get settings
- Cluster health
- Health
- Cluster reroute
- Cluster state
- Cluster stats
- Cluster update settings
- Nodes feature usage
- Nodes hot threads
- Nodes info
- Prevalidate node removal
- Nodes reload secure settings
- Nodes stats
- Cluster Info
- Pending cluster tasks
- Remote cluster info
- Task management
- Voting configuration exclusions
- Create or update desired nodes
- Get desired nodes
- Delete desired nodes
- Get desired balance
- Reset desired balance
- Cross-cluster replication APIs
- Connector APIs
- Create connector
- Delete connector
- Get connector
- List connectors
- Update connector API key id
- Update connector configuration
- Update connector index name
- Update connector features
- Update connector filtering
- Update connector name and description
- Update connector pipeline
- Update connector scheduling
- Update connector service type
- Create connector sync job
- Cancel connector sync job
- Delete connector sync job
- Get connector sync job
- List connector sync jobs
- Check in a connector
- Update connector error
- Update connector last sync stats
- Update connector status
- Check in connector sync job
- Claim connector sync job
- Set connector sync job error
- Set connector sync job stats
- Data stream APIs
- Document APIs
- Enrich APIs
- EQL APIs
- ES|QL APIs
- Features APIs
- Fleet APIs
- Graph explore API
- Index APIs
- Alias exists
- Aliases
- Analyze
- Analyze index disk usage
- Clear cache
- Clone index
- Close index
- Create index
- Create or update alias
- Create or update component template
- Create or update index template
- Create or update index template (legacy)
- Delete component template
- Delete dangling index
- Delete alias
- Delete index
- Delete index template
- Delete index template (legacy)
- Exists
- Field usage stats
- Flush
- Force merge
- Get alias
- Get component template
- Get field mapping
- Get index
- Get index settings
- Get index template
- Get index template (legacy)
- Get mapping
- Import dangling index
- Index recovery
- Index segments
- Index shard stores
- Index stats
- Index template exists (legacy)
- List dangling indices
- Open index
- Refresh
- Resolve index
- Resolve cluster
- Advantages of using this endpoint before a cross-cluster search
- Rollover
- Shrink index
- Simulate index
- Simulate template
- Split index
- Unfreeze index
- Update index settings
- Update mapping
- Index lifecycle management APIs
- Create or update lifecycle policy
- Get policy
- Delete policy
- Move to step
- Remove policy
- Retry policy
- Get index lifecycle management status
- Explain lifecycle
- Start index lifecycle management
- Stop index lifecycle management
- Migrate indices, ILM policies, and legacy, composable and component templates to data tiers routing
- Inference APIs
- Delete inference API
- Get inference API
- Perform inference API
- Create inference API
- Stream inference API
- Update inference API
- AlibabaCloud AI Search inference integration
- Amazon Bedrock inference integration
- Anthropic inference integration
- Azure AI studio inference integration
- Azure OpenAI inference integration
- Cohere inference integration
- Elasticsearch inference integration
- ELSER inference integration
- Google AI Studio inference integration
- Google Vertex AI inference integration
- HuggingFace inference integration
- Mistral inference integration
- OpenAI inference integration
- Watsonx inference integration
- Info API
- Ingest APIs
- Licensing APIs
- Logstash APIs
- Machine learning APIs
- Machine learning anomaly detection APIs
- Add events to calendar
- Add jobs to calendar
- Close jobs
- Create jobs
- Create calendars
- Create datafeeds
- Create filters
- Delete calendars
- Delete datafeeds
- Delete events from calendar
- Delete filters
- Delete forecasts
- Delete jobs
- Delete jobs from calendar
- Delete model snapshots
- Delete expired data
- Estimate model memory
- Flush jobs
- Forecast jobs
- Get buckets
- Get calendars
- Get categories
- Get datafeeds
- Get datafeed statistics
- Get influencers
- Get jobs
- Get job statistics
- Get model snapshots
- Get model snapshot upgrade statistics
- Get overall buckets
- Get scheduled events
- Get filters
- Get records
- Open jobs
- Post data to jobs
- Preview datafeeds
- Reset jobs
- Revert model snapshots
- Start datafeeds
- Stop datafeeds
- Update datafeeds
- Update filters
- Update jobs
- Update model snapshots
- Upgrade model snapshots
- Machine learning data frame analytics APIs
- Create data frame analytics jobs
- Delete data frame analytics jobs
- Evaluate data frame analytics
- Explain data frame analytics
- Get data frame analytics jobs
- Get data frame analytics jobs stats
- Preview data frame analytics
- Start data frame analytics jobs
- Stop data frame analytics jobs
- Update data frame analytics jobs
- Machine learning trained model APIs
- Clear trained model deployment cache
- Create or update trained model aliases
- Create part of a trained model
- Create trained models
- Create trained model vocabulary
- Delete trained model aliases
- Delete trained models
- Get trained models
- Get trained models stats
- Infer trained model
- Start trained model deployment
- Stop trained model deployment
- Update trained model deployment
- Migration APIs
- Node lifecycle APIs
- Query rules APIs
- Reload search analyzers API
- Repositories metering APIs
- Rollup APIs
- Root API
- Script APIs
- Search APIs
- Search Application APIs
- Searchable snapshots APIs
- Security APIs
- Authenticate
- Change passwords
- Clear cache
- Clear roles cache
- Clear privileges cache
- Clear API key cache
- Clear service account token caches
- Create API keys
- Create or update application privileges
- Create or update role mappings
- Create or update roles
- Bulk create or update roles API
- Bulk delete roles API
- Create or update users
- Create service account tokens
- Delegate PKI authentication
- Delete application privileges
- Delete role mappings
- Delete roles
- Delete service account token
- Delete users
- Disable users
- Enable users
- Enroll Kibana
- Enroll node
- Get API key information
- Get application privileges
- Get builtin privileges
- Get role mappings
- Get roles
- Query Role
- Get service accounts
- Get service account credentials
- Get Security settings
- Get token
- Get user privileges
- Get users
- Grant API keys
- Has privileges
- Invalidate API key
- Invalidate token
- OpenID Connect prepare authentication
- OpenID Connect authenticate
- OpenID Connect logout
- Query API key information
- Query User
- Update API key
- Update Security settings
- Bulk update API keys
- SAML prepare authentication
- SAML authenticate
- SAML logout
- SAML invalidate
- SAML complete logout
- SAML service provider metadata
- SSL certificate
- Activate user profile
- Disable user profile
- Enable user profile
- Get user profiles
- Suggest user profile
- Update user profile data
- Has privileges user profile
- Create Cross-Cluster API key
- Update Cross-Cluster API key
- Snapshot and restore APIs
- Snapshot lifecycle management APIs
- SQL APIs
- Synonyms APIs
- Text structure APIs
- Transform APIs
- Usage API
- Watcher APIs
- Definitions
- Command line tools
- elasticsearch-certgen
- elasticsearch-certutil
- elasticsearch-create-enrollment-token
- elasticsearch-croneval
- elasticsearch-keystore
- elasticsearch-node
- elasticsearch-reconfigure-node
- elasticsearch-reset-password
- elasticsearch-saml-metadata
- elasticsearch-service-tokens
- elasticsearch-setup-passwords
- elasticsearch-shard
- elasticsearch-syskeygen
- elasticsearch-users
- Optimizations
- Troubleshooting
- Fix common cluster issues
- Diagnose unassigned shards
- Add a missing tier to the system
- Allow Elasticsearch to allocate the data in the system
- Allow Elasticsearch to allocate the index
- Indices mix index allocation filters with data tiers node roles to move through data tiers
- Not enough nodes to allocate all shard replicas
- Total number of shards for an index on a single node exceeded
- Total number of shards per node has been reached
- Troubleshooting corruption
- Fix data nodes out of disk
- Fix master nodes out of disk
- Fix other role nodes out of disk
- Start index lifecycle management
- Start Snapshot Lifecycle Management
- Restore from snapshot
- Troubleshooting broken repositories
- Addressing repeated snapshot policy failures
- Troubleshooting an unstable cluster
- Troubleshooting discovery
- Troubleshooting monitoring
- Troubleshooting transforms
- Troubleshooting Watcher
- Troubleshooting searches
- Troubleshooting shards capacity health issues
- Troubleshooting an unbalanced cluster
- Capture diagnostics
- Migration guide
- Release notes
- Elasticsearch version 8.17.4
- Elasticsearch version 8.17.3
- Elasticsearch version 8.17.2
- Elasticsearch version 8.17.1
- Elasticsearch version 8.17.0
- Elasticsearch version 8.16.4
- Elasticsearch version 8.16.3
- Elasticsearch version 8.16.2
- Elasticsearch version 8.16.1
- Elasticsearch version 8.16.0
- Elasticsearch version 8.15.5
- Elasticsearch version 8.15.4
- Elasticsearch version 8.15.3
- Elasticsearch version 8.15.2
- Elasticsearch version 8.15.1
- Elasticsearch version 8.15.0
- Elasticsearch version 8.14.3
- Elasticsearch version 8.14.2
- Elasticsearch version 8.14.1
- Elasticsearch version 8.14.0
- Elasticsearch version 8.13.4
- Elasticsearch version 8.13.3
- Elasticsearch version 8.13.2
- Elasticsearch version 8.13.1
- Elasticsearch version 8.13.0
- Elasticsearch version 8.12.2
- Elasticsearch version 8.12.1
- Elasticsearch version 8.12.0
- Elasticsearch version 8.11.4
- Elasticsearch version 8.11.3
- Elasticsearch version 8.11.2
- Elasticsearch version 8.11.1
- Elasticsearch version 8.11.0
- Elasticsearch version 8.10.4
- Elasticsearch version 8.10.3
- Elasticsearch version 8.10.2
- Elasticsearch version 8.10.1
- Elasticsearch version 8.10.0
- Elasticsearch version 8.9.2
- Elasticsearch version 8.9.1
- Elasticsearch version 8.9.0
- Elasticsearch version 8.8.2
- Elasticsearch version 8.8.1
- Elasticsearch version 8.8.0
- Elasticsearch version 8.7.1
- Elasticsearch version 8.7.0
- Elasticsearch version 8.6.2
- Elasticsearch version 8.6.1
- Elasticsearch version 8.6.0
- Elasticsearch version 8.5.3
- Elasticsearch version 8.5.2
- Elasticsearch version 8.5.1
- Elasticsearch version 8.5.0
- Elasticsearch version 8.4.3
- Elasticsearch version 8.4.2
- Elasticsearch version 8.4.1
- Elasticsearch version 8.4.0
- Elasticsearch version 8.3.3
- Elasticsearch version 8.3.2
- Elasticsearch version 8.3.1
- Elasticsearch version 8.3.0
- Elasticsearch version 8.2.3
- Elasticsearch version 8.2.2
- Elasticsearch version 8.2.1
- Elasticsearch version 8.2.0
- Elasticsearch version 8.1.3
- Elasticsearch version 8.1.2
- Elasticsearch version 8.1.1
- Elasticsearch version 8.1.0
- Elasticsearch version 8.0.1
- Elasticsearch version 8.0.0
- Elasticsearch version 8.0.0-rc2
- Elasticsearch version 8.0.0-rc1
- Elasticsearch version 8.0.0-beta1
- Elasticsearch version 8.0.0-alpha2
- Elasticsearch version 8.0.0-alpha1
- Dependencies and versions
Tutorial: semantic search with the inference API
editTutorial: semantic search with the inference API
editThe instructions in this tutorial shows you how to use the inference API workflow with various services to perform semantic search on your data.
For the easiest way to perform semantic search in the Elastic Stack, refer to the semantic_text
end-to-end tutorial.
The following examples use the:
-
embed-english-v3.0
model for Cohere -
all-mpnet-base-v2
model from HuggingFace -
text-embedding-ada-002
second generation embedding model for OpenAI - models available through Azure AI Studio or Azure OpenAI
-
text-embedding-004
model for Google Vertex AI -
mistral-embed
model for Mistral -
amazon.titan-embed-text-v1
model for Amazon Bedrock -
ops-text-embedding-zh-001
model for AlibabaCloud AI
You can use any Cohere and OpenAI models, they are all supported by the inference API. For a list of recommended models available on HuggingFace, refer to the supported model list.
Click the name of the service you want to use on any of the widgets below to review the corresponding instructions.
Requirements
editA Cohere account is required to use the inference API with the Cohere service.
ELSER is a model trained by Elastic. If you have an Elasticsearch deployment, there is no
further requirement for using the inference API with the elasticsearch
service.
A HuggingFace account is required to use the inference API with the HuggingFace service.
An OpenAI account is required to use the inference API with the OpenAI service.
- An Azure subscription
- Access granted to Azure OpenAI in the desired Azure subscription. You can apply for access to Azure OpenAI by completing the form at https://aka.ms/oai/access.
- An embedding model deployed in Azure OpenAI Studio.
- An Azure subscription
- Access to Azure AI Studio
- A deployed embeddings or chat completion model.
- A Google Cloud account
- A project in Google Cloud
- The Vertex AI API enabled in your project
- A valid service account for the Google Vertex AI API
-
The service account must have the Vertex AI User role and the
aiplatform.endpoints.predict
permission.
- A Mistral Account on La Plateforme
- An API key generated for your account
- An AWS Account with Amazon Bedrock access
- A pair of access and secret keys used to access Amazon Bedrock
- An AlibabaCloud Account with AlibabaCloud access
- An API key generated for your account from the API keys section
Create an inference endpoint
editCreate an inference endpoint by using the Create inference API:
resp = client.inference.put( task_type="text_embedding", inference_id="cohere_embeddings", inference_config={ "service": "cohere", "service_settings": { "api_key": "<api_key>", "model_id": "embed-english-v3.0", "embedding_type": "byte" } }, ) print(resp)
const response = await client.inference.put({ task_type: "text_embedding", inference_id: "cohere_embeddings", inference_config: { service: "cohere", service_settings: { api_key: "<api_key>", model_id: "embed-english-v3.0", embedding_type: "byte", }, }, }); console.log(response);
PUT _inference/text_embedding/cohere_embeddings { "service": "cohere", "service_settings": { "api_key": "<api_key>", "model_id": "embed-english-v3.0", "embedding_type": "byte" } }
The task type is |
|
The API key of your Cohere account. You can find your API keys in your Cohere dashboard under the API keys section. You need to provide your API key only once. The Get inference API does not return your API key. |
|
The name of the embedding model to use. You can find the list of Cohere embedding models here. |
When using this model the recommended similarity measure to use in the
dense_vector
field mapping is dot_product
. In the case of Cohere models, the
embeddings are normalized to unit length in which case the dot_product
and
the cosine
measures are equivalent.
resp = client.inference.put( task_type="sparse_embedding", inference_id="elser_embeddings", inference_config={ "service": "elasticsearch", "service_settings": { "num_allocations": 1, "num_threads": 1 } }, ) print(resp)
const response = await client.inference.put({ task_type: "sparse_embedding", inference_id: "elser_embeddings", inference_config: { service: "elasticsearch", service_settings: { num_allocations: 1, num_threads: 1, }, }, }); console.log(response);
PUT _inference/sparse_embedding/elser_embeddings { "service": "elasticsearch", "service_settings": { "num_allocations": 1, "num_threads": 1 } }
The task type is |
You don’t need to download and deploy the ELSER model upfront, the API request above will download the model if it’s not downloaded yet and then deploy it.
You might see a 502 bad gateway error in the response when using the Kibana Console.
This error usually just reflects a timeout, while the model downloads in the background.
You can check the download progress in the Machine Learning UI.
If using the Python client, you can set the timeout
parameter to a higher value.
First, you need to create a new inference endpoint on
the Hugging Face endpoint page to get an
endpoint URL. Select the model all-mpnet-base-v2
on the new endpoint creation
page, then select the Sentence Embeddings
task under the Advanced
configuration section. Create the endpoint. Copy the URL after the endpoint
initialization has been finished, you need the URL in the following inference API
call.
resp = client.inference.put( task_type="text_embedding", inference_id="hugging_face_embeddings", inference_config={ "service": "hugging_face", "service_settings": { "api_key": "<access_token>", "url": "<url_endpoint>" } }, ) print(resp)
const response = await client.inference.put({ task_type: "text_embedding", inference_id: "hugging_face_embeddings", inference_config: { service: "hugging_face", service_settings: { api_key: "<access_token>", url: "<url_endpoint>", }, }, }); console.log(response);
PUT _inference/text_embedding/hugging_face_embeddings { "service": "hugging_face", "service_settings": { "api_key": "<access_token>", "url": "<url_endpoint>" } }
The task type is |
|
A valid HuggingFace access token. You can find on the settings page of your account. |
|
The inference endpoint URL you created on Hugging Face. |
resp = client.inference.put( task_type="text_embedding", inference_id="openai_embeddings", inference_config={ "service": "openai", "service_settings": { "api_key": "<api_key>", "model_id": "text-embedding-ada-002" } }, ) print(resp)
const response = await client.inference.put({ task_type: "text_embedding", inference_id: "openai_embeddings", inference_config: { service: "openai", service_settings: { api_key: "<api_key>", model_id: "text-embedding-ada-002", }, }, }); console.log(response);
PUT _inference/text_embedding/openai_embeddings { "service": "openai", "service_settings": { "api_key": "<api_key>", "model_id": "text-embedding-ada-002" } }
The task type is |
|
The API key of your OpenAI account. You can find your OpenAI API keys in your OpenAI account under the API keys section. You need to provide your API key only once. The Get inference API does not return your API key. |
|
The name of the embedding model to use. You can find the list of OpenAI embedding models here. |
When using this model the recommended similarity measure to use in the
dense_vector
field mapping is dot_product
. In the case of OpenAI models, the
embeddings are normalized to unit length in which case the dot_product
and
the cosine
measures are equivalent.
resp = client.inference.put( task_type="text_embedding", inference_id="azure_openai_embeddings", inference_config={ "service": "azureopenai", "service_settings": { "api_key": "<api_key>", "resource_name": "<resource_name>", "deployment_id": "<deployment_id>", "api_version": "2024-02-01" } }, ) print(resp)
const response = await client.inference.put({ task_type: "text_embedding", inference_id: "azure_openai_embeddings", inference_config: { service: "azureopenai", service_settings: { api_key: "<api_key>", resource_name: "<resource_name>", deployment_id: "<deployment_id>", api_version: "2024-02-01", }, }, }); console.log(response);
PUT _inference/text_embedding/azure_openai_embeddings { "service": "azureopenai", "service_settings": { "api_key": "<api_key>", "resource_name": "<resource_name>", "deployment_id": "<deployment_id>", "api_version": "2024-02-01" } }
The task type is |
|
The API key for accessing your Azure OpenAI services.
Alternately, you can provide an |
|
The name our your Azure resource. |
|
The id of your deployed model. |
It may take a few minutes for your model’s deployment to become available
after it is created. If you try and create the model as above and receive a
404
error message, wait a few minutes and try again.
Also, when using this model the recommended similarity measure to use in the
dense_vector
field mapping is dot_product
.
In the case of Azure OpenAI models, the embeddings are normalized to unit
length in which case the dot_product
and the cosine
measures are equivalent.
resp = client.inference.put( task_type="text_embedding", inference_id="azure_ai_studio_embeddings", inference_config={ "service": "azureaistudio", "service_settings": { "api_key": "<api_key>", "target": "<target_uri>", "provider": "<provider>", "endpoint_type": "<endpoint_type>" } }, ) print(resp)
const response = await client.inference.put({ task_type: "text_embedding", inference_id: "azure_ai_studio_embeddings", inference_config: { service: "azureaistudio", service_settings: { api_key: "<api_key>", target: "<target_uri>", provider: "<provider>", endpoint_type: "<endpoint_type>", }, }, }); console.log(response);
PUT _inference/text_embedding/azure_ai_studio_embeddings { "service": "azureaistudio", "service_settings": { "api_key": "<api_key>", "target": "<target_uri>", "provider": "<provider>", "endpoint_type": "<endpoint_type>" } }
The task type is |
|
The API key for accessing your Azure AI Studio deployed model. You can find this on your model deployment’s overview page. |
|
The target URI for accessing your Azure AI Studio deployed model. You can find this on your model deployment’s overview page. |
|
The model provider, such as |
|
The deployed endpoint type. This can be |
It may take a few minutes for your model’s deployment to become available
after it is created. If you try and create the model as above and receive a
404
error message, wait a few minutes and try again.
Also, when using this model the recommended similarity measure to use in the
dense_vector
field mapping is dot_product
.
resp = client.inference.put( task_type="text_embedding", inference_id="google_vertex_ai_embeddings", inference_config={ "service": "googlevertexai", "service_settings": { "service_account_json": "<service_account_json>", "model_id": "text-embedding-004", "location": "<location>", "project_id": "<project_id>" } }, ) print(resp)
const response = await client.inference.put({ task_type: "text_embedding", inference_id: "google_vertex_ai_embeddings", inference_config: { service: "googlevertexai", service_settings: { service_account_json: "<service_account_json>", model_id: "text-embedding-004", location: "<location>", project_id: "<project_id>", }, }, }); console.log(response);
PUT _inference/text_embedding/google_vertex_ai_embeddings { "service": "googlevertexai", "service_settings": { "service_account_json": "<service_account_json>", "model_id": "text-embedding-004", "location": "<location>", "project_id": "<project_id>" } }
The task type is |
|
A valid service account in JSON format for the Google Vertex AI API. |
|
For the list of the available models, refer to the Text embeddings API page. |
|
The name of the location to use for the inference task. Refer to Generative AI on Vertex AI locations for available locations. |
|
The name of the project to use for the inference task. |
resp = client.inference.put( task_type="text_embedding", inference_id="mistral_embeddings", inference_config={ "service": "mistral", "service_settings": { "api_key": "<api_key>", "model": "<model_id>" } }, ) print(resp)
const response = await client.inference.put({ task_type: "text_embedding", inference_id: "mistral_embeddings", inference_config: { service: "mistral", service_settings: { api_key: "<api_key>", model: "<model_id>", }, }, }); console.log(response);
PUT _inference/text_embedding/mistral_embeddings { "service": "mistral", "service_settings": { "api_key": "<api_key>", "model": "<model_id>" } }
The task type is |
|
The API key for accessing the Mistral API. You can find this in your Mistral account’s API Keys page. |
|
The Mistral embeddings model name, for example |
resp = client.inference.put( task_type="text_embedding", inference_id="amazon_bedrock_embeddings", inference_config={ "service": "amazonbedrock", "service_settings": { "access_key": "<aws_access_key>", "secret_key": "<aws_secret_key>", "region": "<region>", "provider": "<provider>", "model": "<model_id>" } }, ) print(resp)
const response = await client.inference.put({ task_type: "text_embedding", inference_id: "amazon_bedrock_embeddings", inference_config: { service: "amazonbedrock", service_settings: { access_key: "<aws_access_key>", secret_key: "<aws_secret_key>", region: "<region>", provider: "<provider>", model: "<model_id>", }, }, }); console.log(response);
PUT _inference/text_embedding/amazon_bedrock_embeddings { "service": "amazonbedrock", "service_settings": { "access_key": "<aws_access_key>", "secret_key": "<aws_secret_key>", "region": "<region>", "provider": "<provider>", "model": "<model_id>" } }
The task type is |
|
The access key can be found on your AWS IAM management page for the user account to access Amazon Bedrock. |
|
The secret key should be the paired key for the specified access key. |
|
Specify the region that your model is hosted in. |
|
Specify the model provider. |
|
The model ID or ARN of the model to use. |
resp = client.inference.put( task_type="text_embedding", inference_id="alibabacloud_ai_search_embeddings", inference_config={ "service": "alibabacloud-ai-search", "service_settings": { "api_key": "<api_key>", "service_id": "<service_id>", "host": "<host>", "workspace": "<workspace>" } }, ) print(resp)
const response = await client.inference.put({ task_type: "text_embedding", inference_id: "alibabacloud_ai_search_embeddings", inference_config: { service: "alibabacloud-ai-search", service_settings: { api_key: "<api_key>", service_id: "<service_id>", host: "<host>", workspace: "<workspace>", }, }, }); console.log(response);
PUT _inference/text_embedding/alibabacloud_ai_search_embeddings { "service": "alibabacloud-ai-search", "service_settings": { "api_key": "<api_key>", "service_id": "<service_id>", "host": "<host>", "workspace": "<workspace>" } }
The task type is |
|
The API key for accessing the AlibabaCloud AI Search API. You can find your API keys in your AlibabaCloud account under the API keys section. You need to provide your API key only once. The Get inference API does not return your API key. |
|
The AlibabaCloud AI Search embeddings model name, for example |
|
The name our your AlibabaCloud AI Search host address. |
|
The name our your AlibabaCloud AI Search workspace. |
Create the index mapping
editThe mapping of the destination index - the index that contains the embeddings that the model will create based on your input text - must be created.
The destination index must have a field with the dense_vector
field type for most models and the sparse_vector
field type for the sparse vector models like in the case of the elasticsearch
service to index the output of the used model.
resp = client.indices.create( index="cohere-embeddings", mappings={ "properties": { "content_embedding": { "type": "dense_vector", "dims": 1024, "element_type": "byte" }, "content": { "type": "text" } } }, ) print(resp)
response = client.indices.create( index: 'cohere-embeddings', body: { mappings: { properties: { content_embedding: { type: 'dense_vector', dims: 1024, element_type: 'byte' }, content: { type: 'text' } } } } ) puts response
const response = await client.indices.create({ index: "cohere-embeddings", mappings: { properties: { content_embedding: { type: "dense_vector", dims: 1024, element_type: "byte", }, content: { type: "text", }, }, }, }); console.log(response);
PUT cohere-embeddings { "mappings": { "properties": { "content_embedding": { "type": "dense_vector", "dims": 1024, "element_type": "byte" }, "content": { "type": "text" } } } }
The name of the field to contain the generated tokens. It must be refrenced in the inference pipeline configuration in the next step. |
|
The field to contain the tokens is a |
|
The output dimensions of the model. Find this value in the Cohere documentation of the model you use. |
|
The name of the field from which to create the dense vector representation.
In this example, the name of the field is |
|
The field type which is text in this example. |
resp = client.indices.create( index="elser-embeddings", mappings={ "properties": { "content_embedding": { "type": "sparse_vector" }, "content": { "type": "text" } } }, ) print(resp)
const response = await client.indices.create({ index: "elser-embeddings", mappings: { properties: { content_embedding: { type: "sparse_vector", }, content: { type: "text", }, }, }, }); console.log(response);
PUT elser-embeddings { "mappings": { "properties": { "content_embedding": { "type": "sparse_vector" }, "content": { "type": "text" } } } }
The name of the field to contain the generated tokens. It must be refrenced in the inference pipeline configuration in the next step. |
|
The field to contain the tokens is a |
|
The name of the field from which to create the dense vector representation.
In this example, the name of the field is |
|
The field type which is text in this example. |
resp = client.indices.create( index="hugging-face-embeddings", mappings={ "properties": { "content_embedding": { "type": "dense_vector", "dims": 768, "element_type": "float" }, "content": { "type": "text" } } }, ) print(resp)
response = client.indices.create( index: 'hugging-face-embeddings', body: { mappings: { properties: { content_embedding: { type: 'dense_vector', dims: 768, element_type: 'float' }, content: { type: 'text' } } } } ) puts response
const response = await client.indices.create({ index: "hugging-face-embeddings", mappings: { properties: { content_embedding: { type: "dense_vector", dims: 768, element_type: "float", }, content: { type: "text", }, }, }, }); console.log(response);
PUT hugging-face-embeddings { "mappings": { "properties": { "content_embedding": { "type": "dense_vector", "dims": 768, "element_type": "float" }, "content": { "type": "text" } } } }
The name of the field to contain the generated tokens. It must be referenced in the inference pipeline configuration in the next step. |
|
The field to contain the tokens is a |
|
The output dimensions of the model. Find this value in the HuggingFace model documentation. |
|
The name of the field from which to create the dense vector representation.
In this example, the name of the field is |
|
The field type which is text in this example. |
resp = client.indices.create( index="openai-embeddings", mappings={ "properties": { "content_embedding": { "type": "dense_vector", "dims": 1536, "element_type": "float", "similarity": "dot_product" }, "content": { "type": "text" } } }, ) print(resp)
response = client.indices.create( index: 'openai-embeddings', body: { mappings: { properties: { content_embedding: { type: 'dense_vector', dims: 1536, element_type: 'float', similarity: 'dot_product' }, content: { type: 'text' } } } } ) puts response
const response = await client.indices.create({ index: "openai-embeddings", mappings: { properties: { content_embedding: { type: "dense_vector", dims: 1536, element_type: "float", similarity: "dot_product", }, content: { type: "text", }, }, }, }); console.log(response);
PUT openai-embeddings { "mappings": { "properties": { "content_embedding": { "type": "dense_vector", "dims": 1536, "element_type": "float", "similarity": "dot_product" }, "content": { "type": "text" } } } }
The name of the field to contain the generated tokens. It must be referenced in the inference pipeline configuration in the next step. |
|
The field to contain the tokens is a |
|
The output dimensions of the model. Find this value in the OpenAI documentation of the model you use. |
|
The faster` dot_product` function can be used to calculate similarity because OpenAI embeddings are normalised to unit length. You can check the OpenAI docs about which similarity function to use. |
|
The name of the field from which to create the dense vector representation.
In this example, the name of the field is |
|
The field type which is text in this example. |
resp = client.indices.create( index="azure-openai-embeddings", mappings={ "properties": { "content_embedding": { "type": "dense_vector", "dims": 1536, "element_type": "float", "similarity": "dot_product" }, "content": { "type": "text" } } }, ) print(resp)
response = client.indices.create( index: 'azure-openai-embeddings', body: { mappings: { properties: { content_embedding: { type: 'dense_vector', dims: 1536, element_type: 'float', similarity: 'dot_product' }, content: { type: 'text' } } } } ) puts response
const response = await client.indices.create({ index: "azure-openai-embeddings", mappings: { properties: { content_embedding: { type: "dense_vector", dims: 1536, element_type: "float", similarity: "dot_product", }, content: { type: "text", }, }, }, }); console.log(response);
PUT azure-openai-embeddings { "mappings": { "properties": { "content_embedding": { "type": "dense_vector", "dims": 1536, "element_type": "float", "similarity": "dot_product" }, "content": { "type": "text" } } } }
The name of the field to contain the generated tokens. It must be referenced in the inference pipeline configuration in the next step. |
|
The field to contain the tokens is a |
|
The output dimensions of the model. Find this value in the Azure OpenAI documentation of the model you use. |
|
For Azure OpenAI embeddings, the |
|
The name of the field from which to create the dense vector representation.
In this example, the name of the field is |
|
The field type which is text in this example. |
resp = client.indices.create( index="azure-ai-studio-embeddings", mappings={ "properties": { "content_embedding": { "type": "dense_vector", "dims": 1536, "element_type": "float", "similarity": "dot_product" }, "content": { "type": "text" } } }, ) print(resp)
const response = await client.indices.create({ index: "azure-ai-studio-embeddings", mappings: { properties: { content_embedding: { type: "dense_vector", dims: 1536, element_type: "float", similarity: "dot_product", }, content: { type: "text", }, }, }, }); console.log(response);
PUT azure-ai-studio-embeddings { "mappings": { "properties": { "content_embedding": { "type": "dense_vector", "dims": 1536, "element_type": "float", "similarity": "dot_product" }, "content": { "type": "text" } } } }
The name of the field to contain the generated tokens. It must be referenced in the inference pipeline configuration in the next step. |
|
The field to contain the tokens is a |
|
The output dimensions of the model. This value may be found on the model card in your Azure AI Studio deployment. |
|
For Azure AI Studio embeddings, the |
|
The name of the field from which to create the dense vector representation.
In this example, the name of the field is |
|
The field type which is text in this example. |
resp = client.indices.create( index="google-vertex-ai-embeddings", mappings={ "properties": { "content_embedding": { "type": "dense_vector", "dims": 768, "element_type": "float", "similarity": "dot_product" }, "content": { "type": "text" } } }, ) print(resp)
const response = await client.indices.create({ index: "google-vertex-ai-embeddings", mappings: { properties: { content_embedding: { type: "dense_vector", dims: 768, element_type: "float", similarity: "dot_product", }, content: { type: "text", }, }, }, }); console.log(response);
PUT google-vertex-ai-embeddings { "mappings": { "properties": { "content_embedding": { "type": "dense_vector", "dims": 768, "element_type": "float", "similarity": "dot_product" }, "content": { "type": "text" } } } }
The name of the field to contain the generated embeddings. It must be referenced in the inference pipeline configuration in the next step. |
|
The field to contain the embeddings is a |
|
The output dimensions of the model. This value may be found on the Google Vertex AI model reference.
The inference API attempts to calculate the output dimensions automatically if |
|
For Google Vertex AI embeddings, the |
|
The name of the field from which to create the dense vector representation.
In this example, the name of the field is |
|
The field type which is |
resp = client.indices.create( index="mistral-embeddings", mappings={ "properties": { "content_embedding": { "type": "dense_vector", "dims": 1024, "element_type": "float", "similarity": "dot_product" }, "content": { "type": "text" } } }, ) print(resp)
const response = await client.indices.create({ index: "mistral-embeddings", mappings: { properties: { content_embedding: { type: "dense_vector", dims: 1024, element_type: "float", similarity: "dot_product", }, content: { type: "text", }, }, }, }); console.log(response);
PUT mistral-embeddings { "mappings": { "properties": { "content_embedding": { "type": "dense_vector", "dims": 1024, "element_type": "float", "similarity": "dot_product" }, "content": { "type": "text" } } } }
The name of the field to contain the generated tokens. It must be referenced in the inference pipeline configuration in the next step. |
|
The field to contain the tokens is a |
|
The output dimensions of the model. This value may be found on the Mistral model reference. |
|
For Mistral embeddings, the |
|
The name of the field from which to create the dense vector representation.
In this example, the name of the field is |
|
The field type which is text in this example. |
resp = client.indices.create( index="amazon-bedrock-embeddings", mappings={ "properties": { "content_embedding": { "type": "dense_vector", "dims": 1024, "element_type": "float", "similarity": "dot_product" }, "content": { "type": "text" } } }, ) print(resp)
const response = await client.indices.create({ index: "amazon-bedrock-embeddings", mappings: { properties: { content_embedding: { type: "dense_vector", dims: 1024, element_type: "float", similarity: "dot_product", }, content: { type: "text", }, }, }, }); console.log(response);
PUT amazon-bedrock-embeddings { "mappings": { "properties": { "content_embedding": { "type": "dense_vector", "dims": 1024, "element_type": "float", "similarity": "dot_product" }, "content": { "type": "text" } } } }
The name of the field to contain the generated tokens. It must be referenced in the inference pipeline configuration in the next step. |
|
The field to contain the tokens is a |
|
The output dimensions of the model. This value may be different depending on the underlying model used. See the Amazon Titan model or the Cohere Embeddings model documentation. |
|
For Amazon Bedrock embeddings, the |
|
The name of the field from which to create the dense vector representation.
In this example, the name of the field is |
|
The field type which is text in this example. |
resp = client.indices.create( index="alibabacloud-ai-search-embeddings", mappings={ "properties": { "content_embedding": { "type": "dense_vector", "dims": 1024, "element_type": "float" }, "content": { "type": "text" } } }, ) print(resp)
const response = await client.indices.create({ index: "alibabacloud-ai-search-embeddings", mappings: { properties: { content_embedding: { type: "dense_vector", dims: 1024, element_type: "float", }, content: { type: "text", }, }, }, }); console.log(response);
PUT alibabacloud-ai-search-embeddings { "mappings": { "properties": { "content_embedding": { "type": "dense_vector", "dims": 1024, "element_type": "float" }, "content": { "type": "text" } } } }
The name of the field to contain the generated tokens. It must be referenced in the inference pipeline configuration in the next step. |
|
The field to contain the tokens is a |
|
The output dimensions of the model. This value may be different depending on the underlying model used. See the AlibabaCloud AI Search embedding model documentation. |
|
The name of the field from which to create the dense vector representation.
In this example, the name of the field is |
|
The field type which is text in this example. |
Create an ingest pipeline with an inference processor
editCreate an ingest pipeline with an inference processor and use the model you created above to infer against the data that is being ingested in the pipeline.
resp = client.ingest.put_pipeline( id="cohere_embeddings_pipeline", processors=[ { "inference": { "model_id": "cohere_embeddings", "input_output": { "input_field": "content", "output_field": "content_embedding" } } } ], ) print(resp)
const response = await client.ingest.putPipeline({ id: "cohere_embeddings_pipeline", processors: [ { inference: { model_id: "cohere_embeddings", input_output: { input_field: "content", output_field: "content_embedding", }, }, }, ], }); console.log(response);
PUT _ingest/pipeline/cohere_embeddings_pipeline { "processors": [ { "inference": { "model_id": "cohere_embeddings", "input_output": { "input_field": "content", "output_field": "content_embedding" } } } ] }
The name of the inference endpoint you created by using the
Create inference API, it’s referred to as |
|
Configuration object that defines the |
resp = client.ingest.put_pipeline( id="elser_embeddings_pipeline", processors=[ { "inference": { "model_id": "elser_embeddings", "input_output": { "input_field": "content", "output_field": "content_embedding" } } } ], ) print(resp)
const response = await client.ingest.putPipeline({ id: "elser_embeddings_pipeline", processors: [ { inference: { model_id: "elser_embeddings", input_output: { input_field: "content", output_field: "content_embedding", }, }, }, ], }); console.log(response);
PUT _ingest/pipeline/elser_embeddings_pipeline { "processors": [ { "inference": { "model_id": "elser_embeddings", "input_output": { "input_field": "content", "output_field": "content_embedding" } } } ] }
The name of the inference endpoint you created by using the
Create inference API, it’s referred to as |
|
Configuration object that defines the |
resp = client.ingest.put_pipeline( id="hugging_face_embeddings_pipeline", processors=[ { "inference": { "model_id": "hugging_face_embeddings", "input_output": { "input_field": "content", "output_field": "content_embedding" } } } ], ) print(resp)
const response = await client.ingest.putPipeline({ id: "hugging_face_embeddings_pipeline", processors: [ { inference: { model_id: "hugging_face_embeddings", input_output: { input_field: "content", output_field: "content_embedding", }, }, }, ], }); console.log(response);
PUT _ingest/pipeline/hugging_face_embeddings_pipeline { "processors": [ { "inference": { "model_id": "hugging_face_embeddings", "input_output": { "input_field": "content", "output_field": "content_embedding" } } } ] }
The name of the inference endpoint you created by using the
Create inference API, it’s referred to as |
|
Configuration object that defines the |
resp = client.ingest.put_pipeline( id="openai_embeddings_pipeline", processors=[ { "inference": { "model_id": "openai_embeddings", "input_output": { "input_field": "content", "output_field": "content_embedding" } } } ], ) print(resp)
const response = await client.ingest.putPipeline({ id: "openai_embeddings_pipeline", processors: [ { inference: { model_id: "openai_embeddings", input_output: { input_field: "content", output_field: "content_embedding", }, }, }, ], }); console.log(response);
PUT _ingest/pipeline/openai_embeddings_pipeline { "processors": [ { "inference": { "model_id": "openai_embeddings", "input_output": { "input_field": "content", "output_field": "content_embedding" } } } ] }
The name of the inference endpoint you created by using the
Create inference API, it’s referred to as |
|
Configuration object that defines the |
resp = client.ingest.put_pipeline( id="azure_openai_embeddings_pipeline", processors=[ { "inference": { "model_id": "azure_openai_embeddings", "input_output": { "input_field": "content", "output_field": "content_embedding" } } } ], ) print(resp)
const response = await client.ingest.putPipeline({ id: "azure_openai_embeddings_pipeline", processors: [ { inference: { model_id: "azure_openai_embeddings", input_output: { input_field: "content", output_field: "content_embedding", }, }, }, ], }); console.log(response);
PUT _ingest/pipeline/azure_openai_embeddings_pipeline { "processors": [ { "inference": { "model_id": "azure_openai_embeddings", "input_output": { "input_field": "content", "output_field": "content_embedding" } } } ] }
The name of the inference endpoint you created by using the
Create inference API, it’s referred to as |
|
Configuration object that defines the |
resp = client.ingest.put_pipeline( id="azure_ai_studio_embeddings_pipeline", processors=[ { "inference": { "model_id": "azure_ai_studio_embeddings", "input_output": { "input_field": "content", "output_field": "content_embedding" } } } ], ) print(resp)
const response = await client.ingest.putPipeline({ id: "azure_ai_studio_embeddings_pipeline", processors: [ { inference: { model_id: "azure_ai_studio_embeddings", input_output: { input_field: "content", output_field: "content_embedding", }, }, }, ], }); console.log(response);
PUT _ingest/pipeline/azure_ai_studio_embeddings_pipeline { "processors": [ { "inference": { "model_id": "azure_ai_studio_embeddings", "input_output": { "input_field": "content", "output_field": "content_embedding" } } } ] }
The name of the inference endpoint you created by using the
Create inference API, it’s referred to as |
|
Configuration object that defines the |
resp = client.ingest.put_pipeline( id="google_vertex_ai_embeddings_pipeline", processors=[ { "inference": { "model_id": "google_vertex_ai_embeddings", "input_output": { "input_field": "content", "output_field": "content_embedding" } } } ], ) print(resp)
const response = await client.ingest.putPipeline({ id: "google_vertex_ai_embeddings_pipeline", processors: [ { inference: { model_id: "google_vertex_ai_embeddings", input_output: { input_field: "content", output_field: "content_embedding", }, }, }, ], }); console.log(response);
PUT _ingest/pipeline/google_vertex_ai_embeddings_pipeline { "processors": [ { "inference": { "model_id": "google_vertex_ai_embeddings", "input_output": { "input_field": "content", "output_field": "content_embedding" } } } ] }
The name of the inference endpoint you created by using the
Create inference API, it’s referred to as |
|
Configuration object that defines the |
resp = client.ingest.put_pipeline( id="mistral_embeddings_pipeline", processors=[ { "inference": { "model_id": "mistral_embeddings", "input_output": { "input_field": "content", "output_field": "content_embedding" } } } ], ) print(resp)
const response = await client.ingest.putPipeline({ id: "mistral_embeddings_pipeline", processors: [ { inference: { model_id: "mistral_embeddings", input_output: { input_field: "content", output_field: "content_embedding", }, }, }, ], }); console.log(response);
PUT _ingest/pipeline/mistral_embeddings_pipeline { "processors": [ { "inference": { "model_id": "mistral_embeddings", "input_output": { "input_field": "content", "output_field": "content_embedding" } } } ] }
The name of the inference endpoint you created by using the
Create inference API, it’s referred to as |
|
Configuration object that defines the |
resp = client.ingest.put_pipeline( id="amazon_bedrock_embeddings_pipeline", processors=[ { "inference": { "model_id": "amazon_bedrock_embeddings", "input_output": { "input_field": "content", "output_field": "content_embedding" } } } ], ) print(resp)
const response = await client.ingest.putPipeline({ id: "amazon_bedrock_embeddings_pipeline", processors: [ { inference: { model_id: "amazon_bedrock_embeddings", input_output: { input_field: "content", output_field: "content_embedding", }, }, }, ], }); console.log(response);
PUT _ingest/pipeline/amazon_bedrock_embeddings_pipeline { "processors": [ { "inference": { "model_id": "amazon_bedrock_embeddings", "input_output": { "input_field": "content", "output_field": "content_embedding" } } } ] }
The name of the inference endpoint you created by using the
Create inference API, it’s referred to as |
|
Configuration object that defines the |
resp = client.ingest.put_pipeline( id="alibabacloud_ai_search_embeddings_pipeline", processors=[ { "inference": { "model_id": "alibabacloud_ai_search_embeddings", "input_output": { "input_field": "content", "output_field": "content_embedding" } } } ], ) print(resp)
const response = await client.ingest.putPipeline({ id: "alibabacloud_ai_search_embeddings_pipeline", processors: [ { inference: { model_id: "alibabacloud_ai_search_embeddings", input_output: { input_field: "content", output_field: "content_embedding", }, }, }, ], }); console.log(response);
PUT _ingest/pipeline/alibabacloud_ai_search_embeddings_pipeline { "processors": [ { "inference": { "model_id": "alibabacloud_ai_search_embeddings", "input_output": { "input_field": "content", "output_field": "content_embedding" } } } ] }
The name of the inference endpoint you created by using the
Create inference API, it’s referred to as |
|
Configuration object that defines the |
Load data
editIn this step, you load the data that you later use in the inference ingest pipeline to create embeddings from it.
Use the msmarco-passagetest2019-top1000
data set, which is a subset of the MS MARCO Passage Ranking data set.
It consists of 200 queries, each accompanied by a list of relevant text passages.
All unique passages, along with their IDs, have been extracted from that data set and compiled into a
tsv file.
Download the file and upload it to your cluster using the Data Visualizer in the Machine Learning UI.
After your data is analyzed, click Override settings.
Under Edit field names, assign id
to the first column and content
to the second.
Click Apply, then Import.
Name the index test-data
, and click Import.
After the upload is complete, you will see an index named test-data
with 182,469 documents.
Ingest the data through the inference ingest pipeline
editCreate embeddings from the text by reindexing the data through the inference pipeline that uses your chosen model. This step uses the reindex API to simulate data ingestion through a pipeline.
resp = client.reindex( wait_for_completion=False, source={ "index": "test-data", "size": 50 }, dest={ "index": "cohere-embeddings", "pipeline": "cohere_embeddings_pipeline" }, ) print(resp)
const response = await client.reindex({ wait_for_completion: "false", source: { index: "test-data", size: 50, }, dest: { index: "cohere-embeddings", pipeline: "cohere_embeddings_pipeline", }, }); console.log(response);
POST _reindex?wait_for_completion=false { "source": { "index": "test-data", "size": 50 }, "dest": { "index": "cohere-embeddings", "pipeline": "cohere_embeddings_pipeline" } }
The default batch size for reindexing is 1000. Reducing |
The rate limit of your Cohere account may affect the throughput of the reindexing process.
resp = client.reindex( wait_for_completion=False, source={ "index": "test-data", "size": 50 }, dest={ "index": "elser-embeddings", "pipeline": "elser_embeddings_pipeline" }, ) print(resp)
const response = await client.reindex({ wait_for_completion: "false", source: { index: "test-data", size: 50, }, dest: { index: "elser-embeddings", pipeline: "elser_embeddings_pipeline", }, }); console.log(response);
resp = client.reindex( wait_for_completion=False, source={ "index": "test-data", "size": 50 }, dest={ "index": "hugging-face-embeddings", "pipeline": "hugging_face_embeddings_pipeline" }, ) print(resp)
const response = await client.reindex({ wait_for_completion: "false", source: { index: "test-data", size: 50, }, dest: { index: "hugging-face-embeddings", pipeline: "hugging_face_embeddings_pipeline", }, }); console.log(response);
resp = client.reindex( wait_for_completion=False, source={ "index": "test-data", "size": 50 }, dest={ "index": "openai-embeddings", "pipeline": "openai_embeddings_pipeline" }, ) print(resp)
const response = await client.reindex({ wait_for_completion: "false", source: { index: "test-data", size: 50, }, dest: { index: "openai-embeddings", pipeline: "openai_embeddings_pipeline", }, }); console.log(response);
POST _reindex?wait_for_completion=false { "source": { "index": "test-data", "size": 50 }, "dest": { "index": "openai-embeddings", "pipeline": "openai_embeddings_pipeline" } }
The default batch size for reindexing is 1000. Reducing |
The
rate limit of your OpenAI account
may affect the throughput of the reindexing process. If this happens, change
size
to 3
or a similar value in magnitude.
resp = client.reindex( wait_for_completion=False, source={ "index": "test-data", "size": 50 }, dest={ "index": "azure-openai-embeddings", "pipeline": "azure_openai_embeddings_pipeline" }, ) print(resp)
const response = await client.reindex({ wait_for_completion: "false", source: { index: "test-data", size: 50, }, dest: { index: "azure-openai-embeddings", pipeline: "azure_openai_embeddings_pipeline", }, }); console.log(response);
POST _reindex?wait_for_completion=false { "source": { "index": "test-data", "size": 50 }, "dest": { "index": "azure-openai-embeddings", "pipeline": "azure_openai_embeddings_pipeline" } }
The default batch size for reindexing is 1000. Reducing |
The
rate limit of your Azure OpenAI account
may affect the throughput of the reindexing process. If this happens, change
size
to 3
or a similar value in magnitude.
resp = client.reindex( wait_for_completion=False, source={ "index": "test-data", "size": 50 }, dest={ "index": "azure-ai-studio-embeddings", "pipeline": "azure_ai_studio_embeddings_pipeline" }, ) print(resp)
const response = await client.reindex({ wait_for_completion: "false", source: { index: "test-data", size: 50, }, dest: { index: "azure-ai-studio-embeddings", pipeline: "azure_ai_studio_embeddings_pipeline", }, }); console.log(response);
POST _reindex?wait_for_completion=false { "source": { "index": "test-data", "size": 50 }, "dest": { "index": "azure-ai-studio-embeddings", "pipeline": "azure_ai_studio_embeddings_pipeline" } }
The default batch size for reindexing is 1000. Reducing |
Your Azure AI Studio model deployment may have rate limits in place that
might affect the throughput of the reindexing process. If this happens, change
size
to 3
or a similar value in magnitude.
resp = client.reindex( wait_for_completion=False, source={ "index": "test-data", "size": 50 }, dest={ "index": "google-vertex-ai-embeddings", "pipeline": "google_vertex_ai_embeddings_pipeline" }, ) print(resp)
const response = await client.reindex({ wait_for_completion: "false", source: { index: "test-data", size: 50, }, dest: { index: "google-vertex-ai-embeddings", pipeline: "google_vertex_ai_embeddings_pipeline", }, }); console.log(response);
resp = client.reindex( wait_for_completion=False, source={ "index": "test-data", "size": 50 }, dest={ "index": "mistral-embeddings", "pipeline": "mistral_embeddings_pipeline" }, ) print(resp)
const response = await client.reindex({ wait_for_completion: "false", source: { index: "test-data", size: 50, }, dest: { index: "mistral-embeddings", pipeline: "mistral_embeddings_pipeline", }, }); console.log(response);
resp = client.reindex( wait_for_completion=False, source={ "index": "test-data", "size": 50 }, dest={ "index": "amazon-bedrock-embeddings", "pipeline": "amazon_bedrock_embeddings_pipeline" }, ) print(resp)
const response = await client.reindex({ wait_for_completion: "false", source: { index: "test-data", size: 50, }, dest: { index: "amazon-bedrock-embeddings", pipeline: "amazon_bedrock_embeddings_pipeline", }, }); console.log(response);
resp = client.reindex( wait_for_completion=False, source={ "index": "test-data", "size": 50 }, dest={ "index": "alibabacloud-ai-search-embeddings", "pipeline": "alibabacloud_ai_search_embeddings_pipeline" }, ) print(resp)
const response = await client.reindex({ wait_for_completion: "false", source: { index: "test-data", size: 50, }, dest: { index: "alibabacloud-ai-search-embeddings", pipeline: "alibabacloud_ai_search_embeddings_pipeline", }, }); console.log(response);
The call returns a task ID to monitor the progress:
resp = client.tasks.get( task_id="<task_id>", ) print(resp)
const response = await client.tasks.get({ task_id: "<task_id>", }); console.log(response);
GET _tasks/<task_id>
Reindexing large datasets can take a long time. You can test this workflow using only a subset of the dataset. Do this by cancelling the reindexing process, and only generating embeddings for the subset that was reindexed. The following API request will cancel the reindexing task:
resp = client.tasks.cancel( task_id="<task_id>", ) print(resp)
const response = await client.tasks.cancel({ task_id: "<task_id>", }); console.log(response);
POST _tasks/<task_id>/_cancel
Semantic search
editAfter the data set has been enriched with the embeddings, you can query the data using semantic search.
In case of dense vector models, pass a query_vector_builder
to the k-nearest neighbor (kNN) vector search API, and provide the query text and the model you have used to create the embeddings.
In case of a sparse vector model like ELSER, use a sparse_vector
query, and provide the query text with the model you have used to create the embeddings.
If you cancelled the reindexing process, you run the query only a part of the data which affects the quality of your results.
resp = client.search( index="cohere-embeddings", knn={ "field": "content_embedding", "query_vector_builder": { "text_embedding": { "model_id": "cohere_embeddings", "model_text": "Muscles in human body" } }, "k": 10, "num_candidates": 100 }, source=[ "id", "content" ], ) print(resp)
response = client.search( index: 'cohere-embeddings', body: { knn: { field: 'content_embedding', query_vector_builder: { text_embedding: { model_id: 'cohere_embeddings', model_text: 'Muscles in human body' } }, k: 10, num_candidates: 100 }, _source: [ 'id', 'content' ] } ) puts response
const response = await client.search({ index: "cohere-embeddings", knn: { field: "content_embedding", query_vector_builder: { text_embedding: { model_id: "cohere_embeddings", model_text: "Muscles in human body", }, }, k: 10, num_candidates: 100, }, _source: ["id", "content"], }); console.log(response);
GET cohere-embeddings/_search { "knn": { "field": "content_embedding", "query_vector_builder": { "text_embedding": { "model_id": "cohere_embeddings", "model_text": "Muscles in human body" } }, "k": 10, "num_candidates": 100 }, "_source": [ "id", "content" ] }
As a result, you receive the top 10 documents that are closest in meaning to the
query from the cohere-embeddings
index sorted by their proximity to the query:
"hits": [ { "_index": "cohere-embeddings", "_id": "-eFWCY4BECzWLnMZuI78", "_score": 0.737484, "_source": { "id": 1690948, "content": "Oxygen is supplied to the muscles via red blood cells. Red blood cells carry hemoglobin which oxygen bonds with as the hemoglobin rich blood cells pass through the blood vessels of the lungs.The now oxygen rich blood cells carry that oxygen to the cells that are demanding it, in this case skeletal muscle cells.ther ways in which muscles are supplied with oxygen include: 1 Blood flow from the heart is increased. 2 Blood flow to your muscles in increased. 3 Blood flow from nonessential organs is transported to working muscles." } }, { "_index": "cohere-embeddings", "_id": "HuFWCY4BECzWLnMZuI_8", "_score": 0.7176013, "_source": { "id": 1692482, "content": "The thoracic cavity is separated from the abdominal cavity by the diaphragm. This is a broad flat muscle. (muscular) diaphragm The diaphragm is a muscle that separat…e the thoracic from the abdominal cavity. The pelvis is the lowest part of the abdominal cavity and it has no physical separation from it Diaphragm." } }, { "_index": "cohere-embeddings", "_id": "IOFWCY4BECzWLnMZuI_8", "_score": 0.7154432, "_source": { "id": 1692489, "content": "Muscular Wall Separating the Abdominal and Thoracic Cavities; Thoracic Cavity of a Fetal Pig; In Mammals the Diaphragm Separates the Abdominal Cavity from the" } }, { "_index": "cohere-embeddings", "_id": "C-FWCY4BECzWLnMZuI_8", "_score": 0.695313, "_source": { "id": 1691493, "content": "Burning, aching, tenderness and stiffness are just some descriptors of the discomfort you may feel in the muscles you exercised one to two days ago.For the most part, these sensations you experience after exercise are collectively known as delayed onset muscle soreness.urning, aching, tenderness and stiffness are just some descriptors of the discomfort you may feel in the muscles you exercised one to two days ago." } }, (...) ]
resp = client.search( index="elser-embeddings", query={ "sparse_vector": { "field": "content_embedding", "inference_id": "elser_embeddings", "query": "How to avoid muscle soreness after running?" } }, source=[ "id", "content" ], ) print(resp)
const response = await client.search({ index: "elser-embeddings", query: { sparse_vector: { field: "content_embedding", inference_id: "elser_embeddings", query: "How to avoid muscle soreness after running?", }, }, _source: ["id", "content"], }); console.log(response);
GET elser-embeddings/_search { "query":{ "sparse_vector":{ "field": "content_embedding", "inference_id": "elser_embeddings", "query": "How to avoid muscle soreness after running?" } }, "_source": [ "id", "content" ] }
As a result, you receive the top 10 documents that are closest in meaning to the
query from the cohere-embeddings
index sorted by their proximity to the query:
"hits": [ { "_index": "elser-embeddings", "_id": "ZLGc_pABZbBmsu5_eCoH", "_score": 21.472063, "_source": { "id": 2258240, "content": "You may notice some muscle aches while you are exercising. This is called acute soreness. More often, you may begin to feel sore about 12 hours after exercising, and the discomfort usually peaks at 48 to 72 hours after exercise. This is called delayed-onset muscle soreness.It is thought that, during this time, your body is repairing the muscle, making it stronger and bigger.You may also notice the muscles feel better if you exercise lightly. This is normal.his is called delayed-onset muscle soreness. It is thought that, during this time, your body is repairing the muscle, making it stronger and bigger. You may also notice the muscles feel better if you exercise lightly. This is normal." } }, { "_index": "elser-embeddings", "_id": "ZbGc_pABZbBmsu5_eCoH", "_score": 21.421381, "_source": { "id": 2258242, "content": "Photo Credit Jupiterimages/Stockbyte/Getty Images. That stiff, achy feeling you get in the days after exercise is a normal physiological response known as delayed onset muscle soreness. You can take it as a positive sign that your muscles have felt the workout, but the pain may also turn you off to further exercise.ou are more likely to develop delayed onset muscle soreness if you are new to working out, if you’ve gone a long time without exercising and start up again, if you have picked up a new type of physical activity or if you have recently boosted the intensity, length or frequency of your exercise sessions." } }, { "_index": "elser-embeddings", "_id": "ZrGc_pABZbBmsu5_eCoH", "_score": 20.542095, "_source": { "id": 2258248, "content": "They found that stretching before and after exercise has no effect on muscle soreness. Exercise might cause inflammation, which leads to an increase in the production of immune cells (comprised mostly of macrophages and neutrophils). Levels of these immune cells reach a peak 24-48 hours after exercise.These cells, in turn, produce bradykinins and prostaglandins, which make the pain receptors in your body more sensitive. Whenever you move, these pain receptors are stimulated.hey found that stretching before and after exercise has no effect on muscle soreness. Exercise might cause inflammation, which leads to an increase in the production of immune cells (comprised mostly of macrophages and neutrophils). Levels of these immune cells reach a peak 24-48 hours after exercise." } }, (...) ]
resp = client.search( index="hugging-face-embeddings", knn={ "field": "content_embedding", "query_vector_builder": { "text_embedding": { "model_id": "hugging_face_embeddings", "model_text": "What's margin of error?" } }, "k": 10, "num_candidates": 100 }, source=[ "id", "content" ], ) print(resp)
response = client.search( index: 'hugging-face-embeddings', body: { knn: { field: 'content_embedding', query_vector_builder: { text_embedding: { model_id: 'hugging_face_embeddings', model_text: "What's margin of error?" } }, k: 10, num_candidates: 100 }, _source: [ 'id', 'content' ] } ) puts response
const response = await client.search({ index: "hugging-face-embeddings", knn: { field: "content_embedding", query_vector_builder: { text_embedding: { model_id: "hugging_face_embeddings", model_text: "What's margin of error?", }, }, k: 10, num_candidates: 100, }, _source: ["id", "content"], }); console.log(response);
GET hugging-face-embeddings/_search { "knn": { "field": "content_embedding", "query_vector_builder": { "text_embedding": { "model_id": "hugging_face_embeddings", "model_text": "What's margin of error?" } }, "k": 10, "num_candidates": 100 }, "_source": [ "id", "content" ] }
As a result, you receive the top 10 documents that are closest in meaning to the
query from the hugging-face-embeddings
index sorted by their proximity to the query:
"hits": [ { "_index": "hugging-face-embeddings", "_id": "ljEfo44BiUQvMpPgT20E", "_score": 0.8522128, "_source": { "id": 7960255, "content": "The margin of error can be defined by either of the following equations. Margin of error = Critical value x Standard deviation of the statistic. Margin of error = Critical value x Standard error of the statistic. If you know the standard deviation of the statistic, use the first equation to compute the margin of error. Otherwise, use the second equation. Previously, we described how to compute the standard deviation and standard error." } }, { "_index": "hugging-face-embeddings", "_id": "lzEfo44BiUQvMpPgT20E", "_score": 0.7865497, "_source": { "id": 7960259, "content": "1 y ou are told only the size of the sample and are asked to provide the margin of error for percentages which are not (yet) known. 2 This is typically the case when you are computing the margin of error for a survey which is going to be conducted in the future." } }, { "_index": "hugging-face-embeddings1", "_id": "DjEfo44BiUQvMpPgT20E", "_score": 0.6229427, "_source": { "id": 2166183, "content": "1. In general, the point at which gains equal losses. 2. In options, the market price that a stock must reach for option buyers to avoid a loss if they exercise. For a call, it is the strike price plus the premium paid. For a put, it is the strike price minus the premium paid." } }, { "_index": "hugging-face-embeddings1", "_id": "VzEfo44BiUQvMpPgT20E", "_score": 0.6034223, "_source": { "id": 2173417, "content": "How do you find the area of a circle? Can you measure the area of a circle and use that to find a value for Pi?" } }, (...) ]
resp = client.search( index="openai-embeddings", knn={ "field": "content_embedding", "query_vector_builder": { "text_embedding": { "model_id": "openai_embeddings", "model_text": "Calculate fuel cost" } }, "k": 10, "num_candidates": 100 }, source=[ "id", "content" ], ) print(resp)
response = client.search( index: 'openai-embeddings', body: { knn: { field: 'content_embedding', query_vector_builder: { text_embedding: { model_id: 'openai_embeddings', model_text: 'Calculate fuel cost' } }, k: 10, num_candidates: 100 }, _source: [ 'id', 'content' ] } ) puts response
const response = await client.search({ index: "openai-embeddings", knn: { field: "content_embedding", query_vector_builder: { text_embedding: { model_id: "openai_embeddings", model_text: "Calculate fuel cost", }, }, k: 10, num_candidates: 100, }, _source: ["id", "content"], }); console.log(response);
GET openai-embeddings/_search { "knn": { "field": "content_embedding", "query_vector_builder": { "text_embedding": { "model_id": "openai_embeddings", "model_text": "Calculate fuel cost" } }, "k": 10, "num_candidates": 100 }, "_source": [ "id", "content" ] }
As a result, you receive the top 10 documents that are closest in meaning to the
query from the openai-embeddings
index sorted by their proximity to the query:
"hits": [ { "_index": "openai-embeddings", "_id": "DDd5OowBHxQKHyc3TDSC", "_score": 0.83704096, "_source": { "id": 862114, "body": "How to calculate fuel cost for a road trip. By Tara Baukus Mello • Bankrate.com. Dear Driving for Dollars, My family is considering taking a long road trip to finish off the end of the summer, but I'm a little worried about gas prices and our overall fuel cost.It doesn't seem easy to calculate since we'll be traveling through many states and we are considering several routes.y family is considering taking a long road trip to finish off the end of the summer, but I'm a little worried about gas prices and our overall fuel cost. It doesn't seem easy to calculate since we'll be traveling through many states and we are considering several routes." } }, { "_index": "openai-embeddings", "_id": "ajd5OowBHxQKHyc3TDSC", "_score": 0.8345704, "_source": { "id": 820622, "body": "Home Heating Calculator. Typically, approximately 50% of the energy consumed in a home annually is for space heating. When deciding on a heating system, many factors will come into play: cost of fuel, installation cost, convenience and life style are all important.This calculator can help you estimate the cost of fuel for different heating appliances.hen deciding on a heating system, many factors will come into play: cost of fuel, installation cost, convenience and life style are all important. This calculator can help you estimate the cost of fuel for different heating appliances." } }, { "_index": "openai-embeddings", "_id": "Djd5OowBHxQKHyc3TDSC", "_score": 0.8327426, "_source": { "id": 8202683, "body": "Fuel is another important cost. This cost will depend on your boat, how far you travel, and how fast you travel. A 33-foot sailboat traveling at 7 knots should be able to travel 300 miles on 50 gallons of diesel fuel.If you are paying $4 per gallon, the trip would cost you $200.Most boats have much larger gas tanks than cars.uel is another important cost. This cost will depend on your boat, how far you travel, and how fast you travel. A 33-foot sailboat traveling at 7 knots should be able to travel 300 miles on 50 gallons of diesel fuel." } }, (...) ]
resp = client.search( index="azure-openai-embeddings", knn={ "field": "content_embedding", "query_vector_builder": { "text_embedding": { "model_id": "azure_openai_embeddings", "model_text": "Calculate fuel cost" } }, "k": 10, "num_candidates": 100 }, source=[ "id", "content" ], ) print(resp)
response = client.search( index: 'azure-openai-embeddings', body: { knn: { field: 'content_embedding', query_vector_builder: { text_embedding: { model_id: 'azure_openai_embeddings', model_text: 'Calculate fuel cost' } }, k: 10, num_candidates: 100 }, _source: [ 'id', 'content' ] } ) puts response
const response = await client.search({ index: "azure-openai-embeddings", knn: { field: "content_embedding", query_vector_builder: { text_embedding: { model_id: "azure_openai_embeddings", model_text: "Calculate fuel cost", }, }, k: 10, num_candidates: 100, }, _source: ["id", "content"], }); console.log(response);
GET azure-openai-embeddings/_search { "knn": { "field": "content_embedding", "query_vector_builder": { "text_embedding": { "model_id": "azure_openai_embeddings", "model_text": "Calculate fuel cost" } }, "k": 10, "num_candidates": 100 }, "_source": [ "id", "content" ] }
As a result, you receive the top 10 documents that are closest in meaning to the
query from the azure-openai-embeddings
index sorted by their proximity to the query:
"hits": [ { "_index": "azure-openai-embeddings", "_id": "DDd5OowBHxQKHyc3TDSC", "_score": 0.83704096, "_source": { "id": 862114, "body": "How to calculate fuel cost for a road trip. By Tara Baukus Mello • Bankrate.com. Dear Driving for Dollars, My family is considering taking a long road trip to finish off the end of the summer, but I'm a little worried about gas prices and our overall fuel cost.It doesn't seem easy to calculate since we'll be traveling through many states and we are considering several routes.y family is considering taking a long road trip to finish off the end of the summer, but I'm a little worried about gas prices and our overall fuel cost. It doesn't seem easy to calculate since we'll be traveling through many states and we are considering several routes." } }, { "_index": "azure-openai-embeddings", "_id": "ajd5OowBHxQKHyc3TDSC", "_score": 0.8345704, "_source": { "id": 820622, "body": "Home Heating Calculator. Typically, approximately 50% of the energy consumed in a home annually is for space heating. When deciding on a heating system, many factors will come into play: cost of fuel, installation cost, convenience and life style are all important.This calculator can help you estimate the cost of fuel for different heating appliances.hen deciding on a heating system, many factors will come into play: cost of fuel, installation cost, convenience and life style are all important. This calculator can help you estimate the cost of fuel for different heating appliances." } }, { "_index": "azure-openai-embeddings", "_id": "Djd5OowBHxQKHyc3TDSC", "_score": 0.8327426, "_source": { "id": 8202683, "body": "Fuel is another important cost. This cost will depend on your boat, how far you travel, and how fast you travel. A 33-foot sailboat traveling at 7 knots should be able to travel 300 miles on 50 gallons of diesel fuel.If you are paying $4 per gallon, the trip would cost you $200.Most boats have much larger gas tanks than cars.uel is another important cost. This cost will depend on your boat, how far you travel, and how fast you travel. A 33-foot sailboat traveling at 7 knots should be able to travel 300 miles on 50 gallons of diesel fuel." } }, (...) ]
resp = client.search( index="azure-ai-studio-embeddings", knn={ "field": "content_embedding", "query_vector_builder": { "text_embedding": { "model_id": "azure_ai_studio_embeddings", "model_text": "Calculate fuel cost" } }, "k": 10, "num_candidates": 100 }, source=[ "id", "content" ], ) print(resp)
const response = await client.search({ index: "azure-ai-studio-embeddings", knn: { field: "content_embedding", query_vector_builder: { text_embedding: { model_id: "azure_ai_studio_embeddings", model_text: "Calculate fuel cost", }, }, k: 10, num_candidates: 100, }, _source: ["id", "content"], }); console.log(response);
GET azure-ai-studio-embeddings/_search { "knn": { "field": "content_embedding", "query_vector_builder": { "text_embedding": { "model_id": "azure_ai_studio_embeddings", "model_text": "Calculate fuel cost" } }, "k": 10, "num_candidates": 100 }, "_source": [ "id", "content" ] }
As a result, you receive the top 10 documents that are closest in meaning to the
query from the azure-ai-studio-embeddings
index sorted by their proximity to the query:
"hits": [ { "_index": "azure-ai-studio-embeddings", "_id": "DDd5OowBHxQKHyc3TDSC", "_score": 0.83704096, "_source": { "id": 862114, "body": "How to calculate fuel cost for a road trip. By Tara Baukus Mello • Bankrate.com. Dear Driving for Dollars, My family is considering taking a long road trip to finish off the end of the summer, but I'm a little worried about gas prices and our overall fuel cost.It doesn't seem easy to calculate since we'll be traveling through many states and we are considering several routes.y family is considering taking a long road trip to finish off the end of the summer, but I'm a little worried about gas prices and our overall fuel cost. It doesn't seem easy to calculate since we'll be traveling through many states and we are considering several routes." } }, { "_index": "azure-ai-studio-embeddings", "_id": "ajd5OowBHxQKHyc3TDSC", "_score": 0.8345704, "_source": { "id": 820622, "body": "Home Heating Calculator. Typically, approximately 50% of the energy consumed in a home annually is for space heating. When deciding on a heating system, many factors will come into play: cost of fuel, installation cost, convenience and life style are all important.This calculator can help you estimate the cost of fuel for different heating appliances.hen deciding on a heating system, many factors will come into play: cost of fuel, installation cost, convenience and life style are all important. This calculator can help you estimate the cost of fuel for different heating appliances." } }, { "_index": "azure-ai-studio-embeddings", "_id": "Djd5OowBHxQKHyc3TDSC", "_score": 0.8327426, "_source": { "id": 8202683, "body": "Fuel is another important cost. This cost will depend on your boat, how far you travel, and how fast you travel. A 33-foot sailboat traveling at 7 knots should be able to travel 300 miles on 50 gallons of diesel fuel.If you are paying $4 per gallon, the trip would cost you $200.Most boats have much larger gas tanks than cars.uel is another important cost. This cost will depend on your boat, how far you travel, and how fast you travel. A 33-foot sailboat traveling at 7 knots should be able to travel 300 miles on 50 gallons of diesel fuel." } }, (...) ]
resp = client.search( index="google-vertex-ai-embeddings", knn={ "field": "content_embedding", "query_vector_builder": { "text_embedding": { "model_id": "google_vertex_ai_embeddings", "model_text": "Calculate fuel cost" } }, "k": 10, "num_candidates": 100 }, source=[ "id", "content" ], ) print(resp)
const response = await client.search({ index: "google-vertex-ai-embeddings", knn: { field: "content_embedding", query_vector_builder: { text_embedding: { model_id: "google_vertex_ai_embeddings", model_text: "Calculate fuel cost", }, }, k: 10, num_candidates: 100, }, _source: ["id", "content"], }); console.log(response);
GET google-vertex-ai-embeddings/_search { "knn": { "field": "content_embedding", "query_vector_builder": { "text_embedding": { "model_id": "google_vertex_ai_embeddings", "model_text": "Calculate fuel cost" } }, "k": 10, "num_candidates": 100 }, "_source": [ "id", "content" ] }
As a result, you receive the top 10 documents that are closest in meaning to the
query from the mistral-embeddings
index sorted by their proximity to the query:
"hits": [ { "_index": "google-vertex-ai-embeddings", "_id": "Ryv0nZEBBFPLbFsdCbGn", "_score": 0.86815524, "_source": { "id": 3041038, "content": "For example, the cost of the fuel could be 96.9, the amount could be 10 pounds, and the distance covered could be 80 miles. To convert between Litres per 100KM and Miles Per Gallon, please provide a value and click on the required button.o calculate how much fuel you'll need for a given journey, please provide the distance in miles you will be covering on your journey, and the estimated MPG of your vehicle. To work out what MPG you are really getting, please provide the cost of the fuel, how much you spent on the fuel, and how far it took you." } }, { "_index": "google-vertex-ai-embeddings", "_id": "w4j0nZEBZ1nFq1oiHQvK", "_score": 0.8676357, "_source": { "id": 1541469, "content": "This driving cost calculator takes into consideration the fuel economy of the vehicle that you are travelling in as well as the fuel cost. This road trip gas calculator will give you an idea of how much would it cost to drive before you actually travel.his driving cost calculator takes into consideration the fuel economy of the vehicle that you are travelling in as well as the fuel cost. This road trip gas calculator will give you an idea of how much would it cost to drive before you actually travel." } }, { "_index": "google-vertex-ai-embeddings", "_id": "Hoj0nZEBZ1nFq1oiHQjJ", "_score": 0.80510974, "_source": { "id": 7982559, "content": "What's that light cost you? 1 Select your electric rate (or click to enter your own). 2 You can calculate results for up to four types of lights. 3 Select the type of lamp (i.e. 4 Select the lamp wattage (lamp lumens). 5 Enter the number of lights in use. 6 Select how long the lamps are in use (or click to enter your own; enter hours on per year). 7 Finally, ..." } }, (...) ]
resp = client.search( index="mistral-embeddings", knn={ "field": "content_embedding", "query_vector_builder": { "text_embedding": { "model_id": "mistral_embeddings", "model_text": "Calculate fuel cost" } }, "k": 10, "num_candidates": 100 }, source=[ "id", "content" ], ) print(resp)
const response = await client.search({ index: "mistral-embeddings", knn: { field: "content_embedding", query_vector_builder: { text_embedding: { model_id: "mistral_embeddings", model_text: "Calculate fuel cost", }, }, k: 10, num_candidates: 100, }, _source: ["id", "content"], }); console.log(response);
GET mistral-embeddings/_search { "knn": { "field": "content_embedding", "query_vector_builder": { "text_embedding": { "model_id": "mistral_embeddings", "model_text": "Calculate fuel cost" } }, "k": 10, "num_candidates": 100 }, "_source": [ "id", "content" ] }
As a result, you receive the top 10 documents that are closest in meaning to the
query from the mistral-embeddings
index sorted by their proximity to the query:
"hits": [ { "_index": "mistral-embeddings", "_id": "DDd5OowBHxQKHyc3TDSC", "_score": 0.83704096, "_source": { "id": 862114, "body": "How to calculate fuel cost for a road trip. By Tara Baukus Mello • Bankrate.com. Dear Driving for Dollars, My family is considering taking a long road trip to finish off the end of the summer, but I'm a little worried about gas prices and our overall fuel cost.It doesn't seem easy to calculate since we'll be traveling through many states and we are considering several routes.y family is considering taking a long road trip to finish off the end of the summer, but I'm a little worried about gas prices and our overall fuel cost. It doesn't seem easy to calculate since we'll be traveling through many states and we are considering several routes." } }, { "_index": "mistral-embeddings", "_id": "ajd5OowBHxQKHyc3TDSC", "_score": 0.8345704, "_source": { "id": 820622, "body": "Home Heating Calculator. Typically, approximately 50% of the energy consumed in a home annually is for space heating. When deciding on a heating system, many factors will come into play: cost of fuel, installation cost, convenience and life style are all important.This calculator can help you estimate the cost of fuel for different heating appliances.hen deciding on a heating system, many factors will come into play: cost of fuel, installation cost, convenience and life style are all important. This calculator can help you estimate the cost of fuel for different heating appliances." } }, { "_index": "mistral-embeddings", "_id": "Djd5OowBHxQKHyc3TDSC", "_score": 0.8327426, "_source": { "id": 8202683, "body": "Fuel is another important cost. This cost will depend on your boat, how far you travel, and how fast you travel. A 33-foot sailboat traveling at 7 knots should be able to travel 300 miles on 50 gallons of diesel fuel.If you are paying $4 per gallon, the trip would cost you $200.Most boats have much larger gas tanks than cars.uel is another important cost. This cost will depend on your boat, how far you travel, and how fast you travel. A 33-foot sailboat traveling at 7 knots should be able to travel 300 miles on 50 gallons of diesel fuel." } }, (...) ]
resp = client.search( index="amazon-bedrock-embeddings", knn={ "field": "content_embedding", "query_vector_builder": { "text_embedding": { "model_id": "amazon_bedrock_embeddings", "model_text": "Calculate fuel cost" } }, "k": 10, "num_candidates": 100 }, source=[ "id", "content" ], ) print(resp)
const response = await client.search({ index: "amazon-bedrock-embeddings", knn: { field: "content_embedding", query_vector_builder: { text_embedding: { model_id: "amazon_bedrock_embeddings", model_text: "Calculate fuel cost", }, }, k: 10, num_candidates: 100, }, _source: ["id", "content"], }); console.log(response);
GET amazon-bedrock-embeddings/_search { "knn": { "field": "content_embedding", "query_vector_builder": { "text_embedding": { "model_id": "amazon_bedrock_embeddings", "model_text": "Calculate fuel cost" } }, "k": 10, "num_candidates": 100 }, "_source": [ "id", "content" ] }
As a result, you receive the top 10 documents that are closest in meaning to the
query from the amazon-bedrock-embeddings
index sorted by their proximity to the query:
"hits": [ { "_index": "amazon-bedrock-embeddings", "_id": "DDd5OowBHxQKHyc3TDSC", "_score": 0.83704096, "_source": { "id": 862114, "body": "How to calculate fuel cost for a road trip. By Tara Baukus Mello • Bankrate.com. Dear Driving for Dollars, My family is considering taking a long road trip to finish off the end of the summer, but I'm a little worried about gas prices and our overall fuel cost.It doesn't seem easy to calculate since we'll be traveling through many states and we are considering several routes.y family is considering taking a long road trip to finish off the end of the summer, but I'm a little worried about gas prices and our overall fuel cost. It doesn't seem easy to calculate since we'll be traveling through many states and we are considering several routes." } }, { "_index": "amazon-bedrock-embeddings", "_id": "ajd5OowBHxQKHyc3TDSC", "_score": 0.8345704, "_source": { "id": 820622, "body": "Home Heating Calculator. Typically, approximately 50% of the energy consumed in a home annually is for space heating. When deciding on a heating system, many factors will come into play: cost of fuel, installation cost, convenience and life style are all important.This calculator can help you estimate the cost of fuel for different heating appliances.hen deciding on a heating system, many factors will come into play: cost of fuel, installation cost, convenience and life style are all important. This calculator can help you estimate the cost of fuel for different heating appliances." } }, { "_index": "amazon-bedrock-embeddings", "_id": "Djd5OowBHxQKHyc3TDSC", "_score": 0.8327426, "_source": { "id": 8202683, "body": "Fuel is another important cost. This cost will depend on your boat, how far you travel, and how fast you travel. A 33-foot sailboat traveling at 7 knots should be able to travel 300 miles on 50 gallons of diesel fuel.If you are paying $4 per gallon, the trip would cost you $200.Most boats have much larger gas tanks than cars.uel is another important cost. This cost will depend on your boat, how far you travel, and how fast you travel. A 33-foot sailboat traveling at 7 knots should be able to travel 300 miles on 50 gallons of diesel fuel." } }, (...) ]
resp = client.search( index="alibabacloud-ai-search-embeddings", knn={ "field": "content_embedding", "query_vector_builder": { "text_embedding": { "model_id": "alibabacloud_ai_search_embeddings", "model_text": "Calculate fuel cost" } }, "k": 10, "num_candidates": 100 }, source=[ "id", "content" ], ) print(resp)
const response = await client.search({ index: "alibabacloud-ai-search-embeddings", knn: { field: "content_embedding", query_vector_builder: { text_embedding: { model_id: "alibabacloud_ai_search_embeddings", model_text: "Calculate fuel cost", }, }, k: 10, num_candidates: 100, }, _source: ["id", "content"], }); console.log(response);
GET alibabacloud-ai-search-embeddings/_search { "knn": { "field": "content_embedding", "query_vector_builder": { "text_embedding": { "model_id": "alibabacloud_ai_search_embeddings", "model_text": "Calculate fuel cost" } }, "k": 10, "num_candidates": 100 }, "_source": [ "id", "content" ] }
As a result, you receive the top 10 documents that are closest in meaning to the
query from the alibabacloud-ai-search-embeddings
index sorted by their proximity to the query:
"hits": [ { "_index": "alibabacloud-ai-search-embeddings", "_id": "DDd5OowBHxQKHyc3TDSC", "_score": 0.83704096, "_source": { "id": 862114, "body": "How to calculate fuel cost for a road trip. By Tara Baukus Mello • Bankrate.com. Dear Driving for Dollars, My family is considering taking a long road trip to finish off the end of the summer, but I'm a little worried about gas prices and our overall fuel cost.It doesn't seem easy to calculate since we'll be traveling through many states and we are considering several routes.y family is considering taking a long road trip to finish off the end of the summer, but I'm a little worried about gas prices and our overall fuel cost. It doesn't seem easy to calculate since we'll be traveling through many states and we are considering several routes." } }, { "_index": "alibabacloud-ai-search-embeddings", "_id": "ajd5OowBHxQKHyc3TDSC", "_score": 0.8345704, "_source": { "id": 820622, "body": "Home Heating Calculator. Typically, approximately 50% of the energy consumed in a home annually is for space heating. When deciding on a heating system, many factors will come into play: cost of fuel, installation cost, convenience and life style are all important.This calculator can help you estimate the cost of fuel for different heating appliances.hen deciding on a heating system, many factors will come into play: cost of fuel, installation cost, convenience and life style are all important. This calculator can help you estimate the cost of fuel for different heating appliances." } }, { "_index": "alibabacloud-ai-search-embeddings", "_id": "Djd5OowBHxQKHyc3TDSC", "_score": 0.8327426, "_source": { "id": 8202683, "body": "Fuel is another important cost. This cost will depend on your boat, how far you travel, and how fast you travel. A 33-foot sailboat traveling at 7 knots should be able to travel 300 miles on 50 gallons of diesel fuel.If you are paying $4 per gallon, the trip would cost you $200.Most boats have much larger gas tanks than cars.uel is another important cost. This cost will depend on your boat, how far you travel, and how fast you travel. A 33-foot sailboat traveling at 7 knots should be able to travel 300 miles on 50 gallons of diesel fuel." } }, (...) ]
Interactive tutorials
editYou can also find tutorials in an interactive Colab notebook format using the Elasticsearch Python client:
On this page