Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get the number of fields on an index

For optimization purposes, I am trying to cut down my total field count. However before I am going to do that I want to get an idea of how many fields I actually have. There doesn't seem to be any Information in the _stats endpoint and I can't quite figure out how the migration tool does its field count calculation.

Is there some way, either with an endpoint or by other means, to get the total field count of a specified index?

like image 514
Fairy Avatar asked Nov 14 '16 10:11

Fairy


People also ask

How do I get all field names in Elasticsearch?

You may use _field_names field. The _field_names field indexes the names of every field in a document that contains any value other than null. Yes, you may only query for the existence of a field but can't aggregate on the same. The get mappings approach will not work if you are using the join functionality.

What is index field?

You can use an index to help Access find and sort records faster. An index stores the location of records based on the field or fields that you choose to index. After Access obtains the location from the index, it can then retrieve the data by moving directly to the correct location.

Is it possible to select formula based on ID or index?

It will be nice if there is an option to select based on ID or index. It will also be useful while doing multi-field formula with more number of fields, because currently there is no option to write formulaes based on field Name column in it. Jeeva. 05-27-2015 10:25 PM

Is it possible to get all field names in an index?

Yes, this is possible using stats - take a look at this run everywhere example: This will create a list of all field names within index _internal. Adopted to your search this should do it: Hope this helps ... Solved! Jump to solution 10-06-2020 08:27 AM Solved! Jump to solution 01-23-2018 11:56 AM

How to select a field number instead of a field name?

Use the pull down to "Select via a Formula" 2. Expand the "Fields" group in the Variables tab and navigate to the last field option "FieldNumber" 3. [FieldNumber] = 1 returns the first column Does that work? 09-18-2015 10:30 AM I'd very much like the multi-field tool to offer the option of designating field position rather than field name.

How do I select a column in a Dataframe based on index?

Often you may want to select the columns of a pandas DataFrame based on their index value. If you’d like to select columns based on integer indexing, you can use the .iloc function. If you’d like to select columns based on label indexing, you can use the .loc function.


2 Answers

To build a bit further upon what the other answer provided, you can get the mapping and then simply count the number of times the keyword type appears in the output, which gives the number of fields since each field needs a type:

curl -s -XGET localhost:9200/index/_mapping?pretty | grep type | wc -l
like image 104
Val Avatar answered Sep 22 '22 15:09

Val


You can try this:

curl -s -XGET "http://localhost:9200/index/_field_caps?fields=*" | jq '.fields|length'
like image 39
Fred Avatar answered Sep 22 '22 15:09

Fred