How to make use of _meta when using search API


(Peter Ponzel) #1

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


(Peter Ponzel) #3

Anyone could help me?


(Peter Ponzel) #4

Please, anyone?


(Christian Dahlqvist) #5

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


(Peter Ponzel) #6

I was talking about the _meta data for an index ( 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?


(Christian Dahlqvist) #7

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


(Peter Ponzel) #8

Anyone else who might have an idea?


(David Pilato) #9

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.


(Peter Ponzel) #10

that's to bad :frowning: 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 :confused: )


(David Pilato) #11

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

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. 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.


(Christian Dahlqvist) #12

You might be able to use aliases to group indices.


(Peter Ponzel) #13

@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?


(Christian Dahlqvist) #14

Yes, sounds correct.


(Peter Ponzel) #15

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


(system) closed #16

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