# GET API for custom field?

**URL:** <https://discuss.elastic.co/t/get-api-for-custom-field/26856>\
**Category:** Elasticsearch\
**Created:** [August 5, 2015, 8:21am UTC](https://discuss.elastic.co/t/get-api-for-custom-field/26856 "2015-08-05T08:21:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sunilmchaudhari](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sunilmchaudhari/32/9475_2.png) [@sunilmchaudhari](https://discuss.elastic.co/u/sunilmchaudhari)\
**Post date:** [August 5, 2015, 8:21am UTC](https://discuss.elastic.co/t/get-api-for-custom-field/26856/1 "2015-08-05T08:21:20Z")

</div>

Hi,  
We have GET API which can be used to fetch data on specific {index}/{type}{id}, which works fine.

I have xml data which is accepted through http input in logstash shipper. There is one field externalid in xml which is stored under custom field "externalid" in ES.  
I need some way by which I should be able to GET this record with the help for field "extermalid" and not id.

id is some random number which user doesn't even know. But he knows external id and he wants to search on the basis of external id from restclient (firefox)

So the url he expect is http:host:9200/myIndex/myType/{externalid} but its not working. It always check the value of {externalid} under the default field "\_id". How can I change this behaviour?

I have created externalid field in xml filter as below.

```
xpath => [
                    "/ns2:logEntry/event/@ts", "eventLogTime",
                    "/ns2:logEntry/event/extid/text()", "externalid"
              ]

```

Please guide on this. Can I somehow stored **extid** under field \_id ? How can I do that? I tried giving **\_id** in above code in place of **externalid** , but it didnt worked.  
br,  
Sunil

---

<div class="post-metadata">

**Author:** ![Andrei\_Stefan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andrei_stefan/32/47533_2.png) [@Andrei\_Stefan](https://discuss.elastic.co/u/Andrei_Stefan)\
**Post date:** [August 5, 2015, 8:42am UTC](https://discuss.elastic.co/t/get-api-for-custom-field/26856/2 "2015-08-05T08:42:13Z")

</div>

You are looking for `path`: [https://www.elastic.co/guide/en/elasticsearch/reference/1.6/mapping-id-field.html#\_path](https://www.elastic.co/guide/en/elasticsearch/reference/1.6/mapping-id-field.html#_path)  
But note that it's been deprecated starting with ES 1.5.

You could try `http://host:9200/myIndex/myType/_search?q=externalid:{externalid_value}`

---

<div class="post-metadata">

**Author:** ![colings86](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/colings86/32/44960_2.png) [@colings86](https://discuss.elastic.co/u/colings86)\
**Post date:** [August 5, 2015, 8:49am UTC](https://discuss.elastic.co/t/get-api-for-custom-field/26856/3 "2015-08-05T08:49:55Z")

</div>

You can also do this in the elasticsearch output in Logstash by specifying the `document_id` on the output ([https://www.elastic.co/guide/en/logstash/current/plugins-outputs-elasticsearch.html#plugins-outputs-elasticsearch-document\_id](https://www.elastic.co/guide/en/logstash/current/plugins-outputs-elasticsearch.html#plugins-outputs-elasticsearch-document_id)). in your case you would set it to something like `%{external\_id}

---

<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:** [July 5, 2017, 11:57pm UTC](https://discuss.elastic.co/t/get-api-for-custom-field/26856/4 "2017-07-05T23:57:20Z")

</div>


