# How to get all field values of a document which has been set during GetResponse

**URL:** https://discuss.elastic.co/t/how-to-get-all-field-values-of-a-document-which-has-been-set-during-getresponse/16820
**Category:** Elasticsearch
**Created:** [April 4, 2014, 11:38am UTC](https://discuss.elastic.co/t/how-to-get-all-field-values-of-a-document-which-has-been-set-during-getresponse/16820 "2014-04-04T11:38:21Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![bagui](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bagui/32/960_2.png) [@bagui](https://discuss.elastic.co/u/bagui)
#### Post date: [April 4, 2014, 11:38am UTC](https://discuss.elastic.co/t/how-to-get-all-field-values-of-a-document-which-has-been-set-during-getresponse/16820/1 "2014-04-04T11:38:21Z")

</div>

Hi,

I'm to trying to get the filed values of a document which is already been  
set. But I have to pass the field name while doing so.  
In method call I may not know the fields whatever some one has already set.  
Can I get all the fileds from GetField without passing the field name ?

public static GetResponse getResponse(Client client)  
{  
GetResponse response = client.prepareGet("testindex","testtype",  
"1")  
.setFields("author","title")  
.execute().actionGet();  
return response;  
}  
public String getFieldValues()  
{  
Node node = nodeBuilder().client(true).data(false).node();  
Client client = node.client();

GetResponse response = getResponse(client);  
Map\<String, GetField\> respMap = response.getFields();

GetField field = respMap.get("title");  
String fields = (String)field.getValue();

client.close();  
node.close();

```
       return fields;

```

}

Thanks,  
Subhadip

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/010791d9-1e92-45a1-8be4-7df588ba9914%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/010791d9-1e92-45a1-8be4-7df588ba9914%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![Binh\_Ly\_2](https://avatars.discourse-cdn.com/v4/letter/b/d07c76/32.png) [@Binh\_Ly\_2](https://discuss.elastic.co/u/Binh_Ly_2)
#### Post date: [April 4, 2014, 1:44pm UTC](https://discuss.elastic.co/t/how-to-get-all-field-values-of-a-document-which-has-been-set-during-getresponse/16820/2 "2014-04-04T13:44:10Z")

</div>

Maybe something like this?

```
  for(String key: respMap.keySet()){
    GetField field = respMap.get(key);
  }

```

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/07adc3b5-de26-46fe-85c4-718f1c5d18cd%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/07adc3b5-de26-46fe-85c4-718f1c5d18cd%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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 6, 2017, 1:38am UTC](https://discuss.elastic.co/t/how-to-get-all-field-values-of-a-document-which-has-been-set-during-getresponse/16820/3 "2017-07-06T01:38:09Z")

</div>


