# Multiple output sequence

**URL:** <https://discuss.elastic.co/t/multiple-output-sequence/290640>\
**Category:** Logstash\
**Created:** [December 1, 2021, 8:35am UTC](https://discuss.elastic.co/t/multiple-output-sequence/290640 "2021-12-01T08:35:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![zhanggengengen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zhanggengengen/32/97881_2.png) [@zhanggengengen](https://discuss.elastic.co/u/zhanggengengen)\
**Post date:** [December 1, 2021, 8:35am UTC](https://discuss.elastic.co/t/multiple-output-sequence/290640/1 "2021-12-01T08:35:18Z")

</div>

### I have two output,the first is http-output,and the second is elasticsearch-output.

What i want to do is execute http-output before elasticsearch-output.  
How can i do that?  
The problem I have is this I need delete it before I insert into elasticsearch,but I can't determine document\_id, i just hava some field.  
This is my config fragment

```auto
output {

	http {
		url => "http://localhost:9200/image_index/_delete_by_query?pretty"
		content_type => "application/json"
		format => "message"
		http_method => "post"
		message => '{"query":{"term":{"artId":"%{artId}"}}}'
	}
  
	elasticsearch {
		hosts => ["http://localhost:9200"]
		document_type => "_doc"
		index => "image_index"
		document_id => "%{id}"
	}
	
}

```

Or there are other solutions to antipathy?

I need to delete every piece of data that is about to be inserted.  
For example,The data queried from the database is like this

```auto
id artId price
88 12 3.0	
89 12 3.0	
90 66 3.0	
...

```

and now the old data stored in the elasticsearch is like this

```auto
{
"id" : "100",
"artId" : 12,
"price" : 4.0
},
{
"id" : "101",
"artId" : 12,
"price" : 8.0
},
{
"id" : "120",
"artId" : 12,
"price" : 9.0
},
{
"id" : "130",
"artId" : 66,
"price" : 9.0
},
{
"id" : "132",
"artId" : 88,
"price" : 2.2
}
...

```

Before I insert new data, I need delete eligible data from the elasticsearch, because I don't know the document\_id which one I need to delete ,so I had to use http-output to delete these data which artId is '12' or '66', and then insert into elasticsearch by these data queried from the database.  
I wonder if I have described all of that clearly enough.

---

<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:** [December 1, 2021, 7:25pm UTC](https://discuss.elastic.co/t/multiple-output-sequence/290640/2 "2021-12-01T19:25:01Z")

</div>

> [@zhanggengengen](#):
>
> What i want to do is execute http-output before Elasticsearch-output.

You cannot control the order of execution.

Have you considered using artId as the document\_id, so that the old value is overwritten?

---

<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:** [December 29, 2021, 7:25pm UTC](https://discuss.elastic.co/t/multiple-output-sequence/290640/3 "2021-12-29T19:25:41Z")

</div>

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