How can we view all but a few selected fields in an elasticsearch document using http URL?

I can view selected fields in a ES doc using the link "http://localhost:9200/index/type/id?fields=field1,field2,field3"

But my ES doc contains contains many fields and I want to view most of them using a direct url (not using curl etc). Is there a similar way for this as there is for viewing only a selected few of the fields?

Thanks in advance for your guidance.

It is a slightly different question but I don't want to create too many topics. Can we view URL in a pretty mode when we provide fields parameter as well? To view in pretty mode, we add "?pretty" at the end. But I can't add it the same way when I have already added "?fields=........".

HTTP syntax:

GET URL?param1&param2

So it would be:

http://localhost:9200/index/type/id?fields=field1,field2,field3&pretty

I'm not sure I understand the first part of your question. My guess is no: that's not doable unless you are using Shield with platinum license which allows field masking depending on user rights.

1 Like

For the first part, suppose I have 50 fields in an index. I can view a few selected fields using http URL. However, some of the fields contain content extracted from files and take up a lot of space in page. I want view, say 48 fields except two which contain contents extracted from file. I am providing URLs to those files in separate fields. Howver, to manually type 48 fields will be a big burden. I am not sure if it can be done by a simple http URL, where I set properties to view all but those two fields.

Thanks a lot for the second part. :slight_smile:

If the fields are always the same, you could use a query template I think and in the JSON body put the fields you want to see.
Then call search with this template.

I'm guessing you are using mapper attachment.

In 5.0, you will have to use ingest-attachment which won't keep the BASE64 content in source.
Before that you can transform the source doc and exclude the BASE64 with source exclude feature.

I am using ES 2.3.2. I have indexed a SQL DB to ES using java API. My DB contains a field which has address for different pdf/excel etc files. While indexing, I extracted the contents of the file and added them to a separate field named "attachment_content" in ES.

I have created a search box using html and angularjs and providing links to open corresponding SQL record and the file. When the user clicks to view the record, all but the "attachment_content" field should be displayed. It has not to be there as it will take up a lot of page space, and I am already providing link to open the file. For now, I have copied the fields and providing all but one of them in the link to open SQL record. I have to keep it simple for the user and have to give a clickable link that directly opens the record.

I don't think there is a straightforward way to this and maybe have to do with the temporary arrangement of copying all the fields and removing one that is not required.

Thanks for the help.

Even a small project that I am working on has made me realize that ELASTICSEARCH IS A VAST OCEAN.