Elastic Field Types - Range Query

Hello All,
Pretty new to using Elastic and currently using the Serverless option. I have a field called street number , currently it's stored as a text. It contains values which are both string and text:
[100, 101A, 102A, 103, 105-B, 150,]
My use case is I want to use a range query to get all street numbers between 100 & 110. It should output all values including the string values.
My questions is

  1. What's the best way to store this data and retrieve it?

Hi @Karthik_Vaidyanathan,

Welcome to the community! Can you store the number element (101) and letter element (A) as a separate field, and then use a range query similar to the below:

GET /_search
{
  "query": {
    "range": {
      "house_number": {
        "gte": 100,
        "lte": 110
      }
    }
  }
}

Depending on how you are putting your data into Elasticsearch you could create a field with the number portion using different techniques such as:

  1. Pulling the number element using a runtime field.
  2. If you are using Logstash you could create the element using the grok or dissect plugin.
  3. Use similar dissect or grok processors via an ingest pipeline

There will probably be a few other ways to create the field depending on how you are ingesting your data.

Let us know if that helps!