0

I have the following mappings in my elasticsearch index

{
  "test-index" : {
    "mappings" : {
      "properties" : {
        "factor" : {
          "type" : "long"
        },
        "price_range" : {
          "type" : "integer_range",
          "doc_values" : false
        },
        // other_fields
        }
      }
    }
  }
}

The elasticsearch query is an AND query where there will be conditions for "other_fields" and price. Price will need to be calculated on the fly. I want to use the value of "factor" to calculate the price and then match the price with the "price_range" field. Here are the matching conditions:

  1. If "price_range" is indexed, use "factor" to calculate the price and match against "price_range"
  2. If "price_range" is indexed but "factor" is not, use a default value for factor and match against "price_range"
  3. If "price_range" is not indexed, ignore price calculation

Please let me know how can I go about this. Thanks!

Gengis Khan
  • 163
  • 1
  • 2
  • 10
  • https://www.elastic.co/guide/en/elasticsearch/reference/8.6/runtime.html might be able to do it, but I haven't seen anything like that done myself – warkolm Feb 07 '23 at 23:38

0 Answers0