Utilizing Elasticsearch's ELSER Model for Contextual Queries on SQL-Transformed Data

Hi,
I encountered an interesting challenge and was curious whether Elasticsearch's ELSER model could be leveraged to address it.

I've migrated data from SQL to Elasticsearch, where each SQL field is now represented as a field in Elasticsearch.

For instance:

Original SQL Data:

Corresponding JSON in Elasticsearch

{
  "id": 1,
  "name": "John Doe",
  "age": 30,
  "hire_date": "2023-05-01 09:00:00",
  "salary": 75000.50,
  "department_id": 5
}

My goal is to utilize the ELSER model to execute complex, contextual queries across this data. For example, I want to query: "Fetch me 3 employees above 30 years of age in order of the highest salaries."

While I know this could be achieved using Elasticsearch's aggregation queries, I'm looking for a more intuitive solution that could handle natural language questions from end-users and return relevant data.

hey @Het_Test :

This is a good query generation example using a Large Language Model (LLM). This is a blog post that does something similar.

ELSER is geared towards semantic search (being able to find results based on meaning and not just lexical search). You're looking at query generation from natural language, and that is something that some LLM models like ChatGPT can do.