Semantic search with ELSER using .NET client

Semantic search with ELSET guide mention sparce_vector queries

GET my-index/_search
{
   "query":{
      "sparse_vector":{
         "field": "content_embedding",
         "inference_id": "my-elser-endpoint",
         "query": "How to avoid muscle soreness after running?"
      }
   }
}

How to make such requests using Elastic.Clients.Elasticsearch ?

Why SparseVectorQuery is available only in Elastic.Clients.Elasticsearch.Serverless package?

Can Elastic.Clients.Elasticsearch.Serverless client be used instead of Elastic.Clients.Elasticsearch for non-serverless clusters?

@flobernd can you please explain the difference between 2 new clients Elastic.Clients.Elasticsearch.Serverless & Elastic.Clients.Elasticsearch ?

Hi @sergey-tihon,

SparseVectorQuery should indeed be available in the regular stack client as well. I'll investigate why it's currently missing.

The Elastic.Clients.Elasticsearch client is the regular client to connect to the Elasticsearch stack server.

Elastic.Clients.Elasticsearch.Serverless is specifically created to connect to Elasticsearch Serverless deployments.

Current, serverless supports a subset of all available APIs which means that the regular Elastic.Clients.Elasticsearch client can be used as well for connecting to a Serverless instance and visa verce.

1 Like

@sergey-tihon I think you saw the PR on Github already, but for visibility I want to mention here again that the missing 8.15 features are now available starting from the latest 8.15.4 release (should be available on NuGet within the next few minutes).

Thanks for making me aware of the missing functionality :slightly_smiling_face:

@flobernd thank you for such a quick fix.

I am already running 8.15.4 locally and it works for me so far.

1 Like