# How to make use of \_meta when using search API

**URL:** <https://discuss.elastic.co/t/how-to-make-use-of-meta-when-using-search-api/121920>\
**Category:** Elasticsearch\
**Created:** [February 28, 2018, 6:48pm UTC](https://discuss.elastic.co/t/how-to-make-use-of-meta-when-using-search-api/121920 "2018-02-28T18:48:25Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![peter-ponzel](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/peter-ponzel/32/28664_2.png) [@peter-ponzel](https://discuss.elastic.co/u/peter-ponzel)\
**Post date:** [February 28, 2018, 6:48pm UTC](https://discuss.elastic.co/t/how-to-make-use-of-meta-when-using-search-api/121920/1 "2018-02-28T18:48:26Z")

</div>

hello,

is there a way to include the \_meta data of an index when doing a search on multiple indices?  
In my case I have lots of indices which makes it kind of hard to provide them for a search on "Multiple Indices" and also using wildcard to narrow down the indices is not option.  
However I could provide meta data for each index, such as {"visible" : true}.  
With that said, back to my question.. is there a way to make use of \_meta data when searching indices?

Thanks a lot in advance.  
Best regards,  
Peter

---

<div class="post-metadata">

**Author:** ![peter-ponzel](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/peter-ponzel/32/28664_2.png) [@peter-ponzel](https://discuss.elastic.co/u/peter-ponzel)\
**Post date:** [March 4, 2018, 7:28pm UTC](https://discuss.elastic.co/t/how-to-make-use-of-meta-when-using-search-api/121920/3 "2018-03-04T19:28:45Z")

</div>

Anyone could help me?

---

<div class="post-metadata">

**Author:** ![peter-ponzel](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/peter-ponzel/32/28664_2.png) [@peter-ponzel](https://discuss.elastic.co/u/peter-ponzel)\
**Post date:** [March 12, 2018, 8:13am UTC](https://discuss.elastic.co/t/how-to-make-use-of-meta-when-using-search-api/121920/4 "2018-03-12T08:13:51Z")

</div>

Please, anyone?

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [March 12, 2018, 8:31am UTC](https://discuss.elastic.co/t/how-to-make-use-of-meta-when-using-search-api/121920/5 "2018-03-12T08:31:44Z")

</div>

What type of metadata are you referring to? Where is this stored?

---

<div class="post-metadata">

**Author:** ![peter-ponzel](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/peter-ponzel/32/28664_2.png) [@peter-ponzel](https://discuss.elastic.co/u/peter-ponzel)\
**Post date:** [March 12, 2018, 9:46am UTC](https://discuss.elastic.co/t/how-to-make-use-of-meta-when-using-search-api/121920/6 "2018-03-12T09:46:01Z")

</div>

I was talking about the **\_meta** data for an index ( [https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-meta-field.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-meta-field.html) )

@Christian_Dahlqvist  
and my question is, when I'm adding data _there_ in the meta data, can I make use of it when doing a search for documents on all indices?

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [March 14, 2018, 11:54am UTC](https://discuss.elastic.co/t/how-to-make-use-of-meta-when-using-search-api/121920/7 "2018-03-14T11:54:05Z")

</div>

Not as far as I know, but am not entirely certain. Might need to wait some someone else to chime in.

---

<div class="post-metadata">

**Author:** ![peter-ponzel](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/peter-ponzel/32/28664_2.png) [@peter-ponzel](https://discuss.elastic.co/u/peter-ponzel)\
**Post date:** [March 22, 2018, 9:00am UTC](https://discuss.elastic.co/t/how-to-make-use-of-meta-when-using-search-api/121920/8 "2018-03-22T09:00:47Z")

</div>

Anyone else who might have an idea?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 22, 2018, 9:14am UTC](https://discuss.elastic.co/t/how-to-make-use-of-meta-when-using-search-api/121920/9 "2018-03-22T09:14:05Z")

</div>

> can I make use of it when doing a search for documents on all indices?

No. It's only part of the mapping. It's not part of documents.

---

<div class="post-metadata">

**Author:** ![peter-ponzel](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/peter-ponzel/32/28664_2.png) [@peter-ponzel](https://discuss.elastic.co/u/peter-ponzel)\
**Post date:** [March 22, 2018, 9:43am UTC](https://discuss.elastic.co/t/how-to-make-use-of-meta-when-using-search-api/121920/10 "2018-03-22T09:43:11Z")

</div>

that's to bad ☹ is there any other way to archive a single search on a great number of indices, without having to name them? (wildcards won't do I'm affraid 😕 )

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 22, 2018, 11:07am UTC](https://discuss.elastic.co/t/how-to-make-use-of-meta-when-using-search-api/121920/11 "2018-03-22T11:07:41Z")

</div>

I don't understand the relationship between the original question and this question:

> is there any other way to archive a single search on a great number of indices

> wildcards won't do I'm affraid

Searching for

```auto
GET foo*/_search

```

is fine.

It's unclear to me what you are trying to achieve here.

Could you provide a full recreation script as described in [About the Elasticsearch category](https://discuss.elastic.co/t/about-the-elasticsearch-category/21). It will help to better understand what you are doing. Please, try to keep the example as simple as possible.

A full reproduction script will help readers to understand, reproduce and if needed fix your problem. It will also most likely help to get a faster answer.

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [March 22, 2018, 11:12am UTC](https://discuss.elastic.co/t/how-to-make-use-of-meta-when-using-search-api/121920/12 "2018-03-22T11:12:15Z")

</div>

You might be able to use [aliases](https://www.elastic.co/guide/en/elasticsearch/reference/6.2/indices-aliases.html) to group indices.

---

<div class="post-metadata">

**Author:** ![peter-ponzel](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/peter-ponzel/32/28664_2.png) [@peter-ponzel](https://discuss.elastic.co/u/peter-ponzel)\
**Post date:** [March 22, 2018, 12:47pm UTC](https://discuss.elastic.co/t/how-to-make-use-of-meta-when-using-search-api/121920/13 "2018-03-22T12:47:04Z")

</div>

@dadoonet sorry, english is not my mother tongue.. I mean that I can't use wildcards in my case, because there is not a pattern that I can apply.. for instance I have a list of indices, such as

- contracts
- plans
- notes
- ..and way more..

lots of these indices are "public" (this information is stored in \__meta_ data at the moment)  
but a few indices are private (in relation "a few".. they're still quite a lot of them)  
.. and what I want to do/archive is to do a search on all "public" indices.

@Christian_Dahlqvist thank you for mentioning aliases. It looks like that I can do exactly what I want.  
If I understood it correctly, then I could create an alias called "public" and just add all my "public" indices to it.. and when I want to search on all "public" indices, then I'll just have to call

> GET public/\_search

is that somewhat correct?

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [March 22, 2018, 1:09pm UTC](https://discuss.elastic.co/t/how-to-make-use-of-meta-when-using-search-api/121920/14 "2018-03-22T13:09:55Z")

</div>

Yes, sounds correct.

---

<div class="post-metadata">

**Author:** ![peter-ponzel](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/peter-ponzel/32/28664_2.png) [@peter-ponzel](https://discuss.elastic.co/u/peter-ponzel)\
**Post date:** [April 3, 2018, 8:25am UTC](https://discuss.elastic.co/t/how-to-make-use-of-meta-when-using-search-api/121920/15 "2018-04-03T08:25:22Z")

</div>

With aliases it works like a charm 🙂 thank you both for your help.

---

<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:** [May 1, 2018, 8:25am UTC](https://discuss.elastic.co/t/how-to-make-use-of-meta-when-using-search-api/121920/16 "2018-05-01T08:25:35Z")

</div>

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