# Search for available fields

**URL:** <https://discuss.elastic.co/t/search-for-available-fields/20013>\
**Category:** Elasticsearch\
**Created:** [September 30, 2014, 3:15pm UTC](https://discuss.elastic.co/t/search-for-available-fields/20013 "2014-09-30T15:15:32Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![shooali](https://avatars.discourse-cdn.com/v4/letter/s/c89c15/32.png) [@shooali](https://discuss.elastic.co/u/shooali)\
**Post date:** [September 30, 2014, 3:15pm UTC](https://discuss.elastic.co/t/search-for-available-fields/20013/1 "2014-09-30T15:15:32Z")

</div>

Hi,

What is the most efficient way to get all available fields to search on for  
a preliminary search criteria?

Thanks,

Shooali

--  
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/db45232a-a454-4ee8-b2b6-4a8f0a7f3d41%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/db45232a-a454-4ee8-b2b6-4a8f0a7f3d41%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![brian\_yoder](https://avatars.discourse-cdn.com/v4/letter/b/f1d935/32.png) [@brian\_yoder](https://discuss.elastic.co/u/brian_yoder)\
**Post date:** [September 30, 2014, 3:24pm UTC](https://discuss.elastic.co/t/search-for-available-fields/20013/2 "2014-09-30T15:24:26Z")

</div>

The following query will return all of the mappings for all of the indices  
on the specified ES host:

$ curl -XGET 'http://_hostname_:9200/\_all/\_mapping?pretty=true' && echo

You can read the JSON, or else parse it and extract the details you need.  
For example, if you have automatic mapping enabled, this is a very good way  
to not only discover the searchable fields but also see if they are strings  
or numbers.

Brian

On Tuesday, September 30, 2014 11:15:32 AM UTC-4, shooali wrote:

> Hi,
> 
> What is the most efficient way to get all available fields to search on  
> for a preliminary search criteria?
> 
> Thanks,
> 
> Shooali

--  
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/95cd8e08-bba6-451c-96c5-8e3c6a1e1fff%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/95cd8e08-bba6-451c-96c5-8e3c6a1e1fff%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![shooali](https://avatars.discourse-cdn.com/v4/letter/s/c89c15/32.png) [@shooali](https://discuss.elastic.co/u/shooali)\
**Post date:** [September 30, 2014, 10:01pm UTC](https://discuss.elastic.co/t/search-for-available-fields/20013/3 "2014-09-30T22:01:20Z")

</div>

Thank you Brian,

However, I am looking for something slightly different. I don't want to  
know all the fields for an index, I want to know for a certain subset of  
the documents I have indexed, what are the relevant fields that I can  
continue search on. For example:  
If I have 5 fields total for my index, Then I search for all document that  
satisfy certain criteria, for example, all documents that FieldA equals  
'5'. Only for those, what are the available fields that I can continue on  
search on...  
The way I thought I can do this is to go over all result of the first  
search and collect all fields of these documents into a Set and use those.  
My question is whether there is a better/more performant way to achieve  
this goal.

Thanks,

On Tuesday, September 30, 2014 6:24:26 PM UTC+3, Brian wrote:

> The following query will return all of the mappings for all of the indices  
> on the specified ES host:
> 
> $ curl -XGET 'http://_hostname_:9200/\_all/\_mapping?pretty=true' && echo
> 
> You can read the JSON, or else parse it and extract the details you need.  
> For example, if you have automatic mapping enabled, this is a very good way  
> to not only discover the searchable fields but also see if they are strings  
> or numbers.
> 
> Brian
> 
> On Tuesday, September 30, 2014 11:15:32 AM UTC-4, shooali wrote:
> 
> > Hi,
> > 
> > What is the most efficient way to get all available fields to search on  
> > for a preliminary search criteria?
> > 
> > Thanks,
> > 
> > Shooali

--  
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/83dedc03-4193-41ea-9fa6-1d0ac2a0df98%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/83dedc03-4193-41ea-9fa6-1d0ac2a0df98%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![brian\_yoder](https://avatars.discourse-cdn.com/v4/letter/b/f1d935/32.png) [@brian\_yoder](https://discuss.elastic.co/u/brian_yoder)\
**Post date:** [October 2, 2014, 6:56pm UTC](https://discuss.elastic.co/t/search-for-available-fields/20013/4 "2014-10-02T18:56:55Z")

</div>

In that case, your strategy seems fine. ES has already done all the real  
work of creating the responses, and I would expect that iterating across  
them and gathering the fields into a Set should be rather quick.

However, you still might wish to get the mappings for the index. Why?  
Because once you've collected the subset of fields within your current  
response, you still can only search on the ones that are indexed. So for a  
general solution, you would perhaps want to skip over fields that are  
stored in the documents but not indexed.

Brian

On Tuesday, September 30, 2014 6:01:20 PM UTC-4, shooali wrote:

> Thank you Brian,
> 
> However, I am looking for something slightly different. I don't want to  
> know all the fields for an index, I want to know for a certain subset of  
> the documents I have indexed, what are the relevant fields that I can  
> continue search on. For example:  
> If I have 5 fields total for my index, Then I search for all document that  
> satisfy certain criteria, for example, all documents that FieldA equals  
> '5'. Only for those, what are the available fields that I can continue on  
> search on...  
> The way I thought I can do this is to go over all result of the first  
> search and collect all fields of these documents into a Set and use those.  
> My question is whether there is a better/more performant way to achieve  
> this goal.

--  
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/4ae1168c-2526-4ba6-937a-1f2b1bc90a0b%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/4ae1168c-2526-4ba6-937a-1f2b1bc90a0b%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, 12:58am UTC](https://discuss.elastic.co/t/search-for-available-fields/20013/5 "2017-07-06T00:58:35Z")

</div>


