# Is it possible to update Elasticsearch using logstash conf file with field other than document id

**URL:** <https://discuss.elastic.co/t/is-it-possible-to-update-elasticsearch-using-logstash-conf-file-with-field-other-than-document-id/299203>\
**Category:** Logstash\
**Created:** [March 9, 2022, 11:20am UTC](https://discuss.elastic.co/t/is-it-possible-to-update-elasticsearch-using-logstash-conf-file-with-field-other-than-document-id/299203 "2022-03-09T11:20:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![RAM\_NATHAN](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ram_nathan/32/50393_2.png) [@RAM\_NATHAN](https://discuss.elastic.co/u/RAM_NATHAN)\
**Post date:** [March 9, 2022, 11:20am UTC](https://discuss.elastic.co/t/is-it-possible-to-update-elasticsearch-using-logstash-conf-file-with-field-other-than-document-id/299203/1 "2022-03-09T11:20:55Z")

</div>

Hello

```auto
   if[sid]!="null" and [sid]!=""
		   {
            elasticsearch
            {
               hosts => ["localhost:9200"]
               document_id => "%{sid}"
               index => "dashboard_write"
                script => "if(ctx._source.appdata== null)
                         {
                           ctx._source.appdata = new ArrayList(); 
                        } 
                        ctx._source.appdata.add(params.event.get('appdata'))"
              doc_as_upsert => "true"

               action => "update"
			   ilm_enabled => false
            }
			}
			else
			{
			elasticsearch
            {
               hosts => ["localhost:9200"]
               index => "dashboard_write"
			   ilm_enabled => false
            }
			}
     
       
       
        }

```

Here Im updating Elasticsearch doc based on sid field. But this sid will be stored in a document as a fieild "authsid"

So I need a if condition like this

if [sid= authsid field in one of the document]  
update that document  
else  
insert this as new document

I know this is complicated design, but I just wanted to know is this possible??

---

<div class="post-metadata">

**Author:** ![RAM\_NATHAN](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ram_nathan/32/50393_2.png) [@RAM\_NATHAN](https://discuss.elastic.co/u/RAM_NATHAN)\
**Post date:** [March 14, 2022, 3:52am UTC](https://discuss.elastic.co/t/is-it-possible-to-update-elasticsearch-using-logstash-conf-file-with-field-other-than-document-id/299203/2 "2022-03-14T03:52:21Z")

</div>

Can someone please update

---

<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:** [April 11, 2022, 3:52am UTC](https://discuss.elastic.co/t/is-it-possible-to-update-elasticsearch-using-logstash-conf-file-with-field-other-than-document-id/299203/3 "2022-04-11T03:52:25Z")

</div>

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