# How to get all Field names with filter(or query) criteria on ElasticSearch?

**URL:** <https://discuss.elastic.co/t/how-to-get-all-field-names-with-filter-or-query-criteria-on-elasticsearch/283435>\
**Category:** Elasticsearch\
**Created:** [September 6, 2021, 10:35am UTC](https://discuss.elastic.co/t/how-to-get-all-field-names-with-filter-or-query-criteria-on-elasticsearch/283435 "2021-09-06T10:35:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jinssssun](https://avatars.discourse-cdn.com/v4/letter/j/7ea924/32.png) [@jinssssun](https://discuss.elastic.co/u/jinssssun)\
**Post date:** [September 6, 2021, 10:35am UTC](https://discuss.elastic.co/t/how-to-get-all-field-names-with-filter-or-query-criteria-on-elasticsearch/283435/1 "2021-09-06T10:35:27Z")

</div>

```auto
PUT /test-product
{
  "mappings": {
    "properties": {
      "profile": {
        "type": "nested"
      },
      "product": {
        "type": "nested"
      }
    }
  }
}

```

i have a index that name's 'test-product'

```auto
POST /test-product/_bulk
{ "index" : { "_id" : "1" } }
{ "user":"1", "profile":{"name":"AA", "age": "11", "height": "30"}, "product": {"price": "333", "name": "test", "weight": "10"} }
{ "index" : { "_id" : "2" } }
{ "user":"2", "profile":{"name":"BB", "age": "20"}, "product": {"name": "test"}}

```

and that index have some docs

I want to get the results as below....

Case 1. when i search for user: 1

profile.name, profile.age, profile.height, product.price, product.name, product.weight

Case 2. when i search for user: 2

profile.name, profile.age, product.name

Is there a way?

---

<div class="post-metadata">

**Author:** ![Jaymin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jaymin/32/77509_2.png) [@Jaymin](https://discuss.elastic.co/u/Jaymin)\
**Post date:** [September 6, 2021, 12:34pm UTC](https://discuss.elastic.co/t/how-to-get-all-field-names-with-filter-or-query-criteria-on-elasticsearch/283435/2 "2021-09-06T12:34:45Z")

</div>

> [@jinssssun](#):
>
> Case 2. when i search for user: 2

elasticsearch will return all the data which are indexed. so you have to index those fields that you want from query

---

<div class="post-metadata">

**Author:** ![jinssssun](https://avatars.discourse-cdn.com/v4/letter/j/7ea924/32.png) [@jinssssun](https://discuss.elastic.co/u/jinssssun)\
**Post date:** [September 6, 2021, 12:40pm UTC](https://discuss.elastic.co/t/how-to-get-all-field-names-with-filter-or-query-criteria-on-elasticsearch/283435/3 "2021-09-06T12:40:09Z")

</div>

Okay, i guess so.

It would look like this if i created an index.

user | keyName  
1 | profile.name  
1 | profile.age  
1 | profile.height  
1 | product.price  
1 | product.name  
1 | product.weight  
2 | profile.name  
2 | profile.age  
2 | product.name

I'll have to look for another data source..

thanks

---

<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:** [October 4, 2021, 12:40pm UTC](https://discuss.elastic.co/t/how-to-get-all-field-names-with-filter-or-query-criteria-on-elasticsearch/283435/4 "2021-10-04T12:40:36Z")

</div>

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