GET API for custom field?

(Sunil Chaudhari) #1

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.

(Andrei Stefan) #2

You are looking for 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}

(Colin Goodheart-Smithe) #3

You can also do this in the elasticsearch output in Logstash by specifying the document_id on the output ( in your case you would set it to something like `%{external_id}

(system) #4