toptal / chewy

High-level Elasticsearch Ruby framework based on the official elasticsearch-ruby client
MIT License
1.88k stars 366 forks source link

Add runtime_mappings support #887

Open TakuyaKurimoto opened 1 year ago

TakuyaKurimoto commented 1 year ago

Hello. One time I wanted to use runtime_mappings, but in chewy I had to write the following code because chewy does not support runtime_mappings .

q = HogeIndex.query({}).render
q[:body][:runtime_mappings] = {"field1"=>{type: 'keyword', :script=>{:lang=>"painless", :source=>"emit('some script here')"}}}
HogeIndex.client.search(body: q[:body])

This is a bit inconvenient, so I was wondering if you could support runtime_mappings in chewy as well?

If this code is merged, it will be possible to do something like the code below

CitiesIndex
  .runtime_mappings(
    field1: {
      type: 'keyword',
      :script=>{
        :lang=>"painless",
        :source=>"emit('some script here')"
      }
    }
  )
  .aggs(
    field1: {
      terms: {
        field: "field1"
      }
    }
  )

Before submitting the PR make sure the following are checked:

konalegi commented 1 year ago

@TakuyaKurimoto Thanks for the PR! unfortunately I'm not familiar with the runtime mappings features, let me learn it and get back to you.

TakuyaKurimoto commented 1 year ago

OK! I'm sorry for bothering you.

TakuyaKurimoto commented 1 year ago

@konalegi sorry for bothering you. Any updates on that one?