# Elastic\_app\_search set engine based on document value

**URL:** <https://discuss.elastic.co/t/elastic-app-search-set-engine-based-on-document-value/252079>\
**Category:** Logstash\
**Created:** [October 14, 2020, 5:13pm UTC](https://discuss.elastic.co/t/elastic-app-search-set-engine-based-on-document-value/252079 "2020-10-14T17:13:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tam2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tam2/32/68143_2.png) [@Tam2](https://discuss.elastic.co/u/Tam2)\
**Post date:** [October 14, 2020, 5:13pm UTC](https://discuss.elastic.co/t/elastic-app-search-set-engine-based-on-document-value/252079/1 "2020-10-14T17:13:13Z")

</div>

Within my document, there is a client\_id field

I would like to set the engine for my elastic\_app\_search based on this value. So each document goes into the correct engine based on the document's client\_id

I tried to do this but it doesn't work (setting the engine value to an actual value does work)

```auto
output { 
  elastic_app_search {
    api_key => "private-XXX"
   engine => "%{client_id}"
    url => "https://XXX.ent-search.eu-west-2.aws.cloud.es.io"
  }
 
}

```

Gives me the below error:

```auto
[2020-10-14T18:12:18,775][ERROR][logstash.agent] Failed to execute action {:id=>:main, :action_type=>LogStash::ConvergeResult::FailedAction, :message=>"Could not execute action: PipelineAction::Create<main>, action_result: false", :backtrace=>nil}

```

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [October 14, 2020, 5:24pm UTC](https://discuss.elastic.co/t/elastic-app-search-set-engine-based-on-document-value/252079/2 "2020-10-14T17:24:55Z")

</div>

Set log.level to debug and see if you get a more informative error message.

That said, I see no suggestion in the [code](https://github.com/logstash-plugins/logstash-output-elastic_app_search/blob/master/lib/logstash/outputs/elastic_app_search.rb) that sprintf references are supported.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [November 11, 2020, 5:25pm UTC](https://discuss.elastic.co/t/elastic-app-search-set-engine-based-on-document-value/252079/3 "2020-11-11T17:25:14Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
