├── .gitignore ├── LICENSE ├── Makefile ├── README.md ├── bin ├── es ├── release ├── save └── test ├── etc ├── commons-logging.properties └── log4j.properties ├── hs ├── Es2Unix │ ├── Health.hs │ └── Indices.hs └── es.hs ├── project.clj ├── src └── es │ ├── command.clj │ ├── command │ ├── allocation.clj │ ├── count.clj │ ├── health.clj │ ├── heap.clj │ ├── ids.clj │ ├── indices.clj │ ├── lifecycle.clj │ ├── master.clj │ ├── nodes.clj │ ├── search.clj │ ├── shards.clj │ └── version.clj │ ├── data │ ├── cluster.clj │ ├── indices.clj │ ├── nodes.clj │ ├── replica.clj │ └── search.clj │ ├── format │ ├── error.clj │ ├── network.clj │ ├── table.clj │ └── uri.clj │ ├── help.clj │ ├── http.clj │ ├── local.clj │ ├── main.clj │ ├── util.clj │ └── util │ ├── math.clj │ └── time.clj └── test └── output ├── _cluster ├── health.json ├── nodes.json └── state?filter_metadata=1&filter_routing_table=1&filter_indices=1.json ├── _nodes.json ├── _status.json └── wik* └── _status.json /.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /lib 3 | /classes 4 | /checkouts 5 | pom.xml 6 | *.jar 7 | *.class 8 | .lein-deps-sum 9 | .lein-failures 10 | .lein-plugins 11 | /etc/version.txt 12 | /tmp 13 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2012-2013 Elasticsearch BV 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); you 4 | may not use this file except in compliance with the License. You may 5 | obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 12 | implied. See the License for the specific language governing 13 | permissions and limitations under the License. 14 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | LEIN ?= lein 2 | NAME = es 3 | VERSION = $(shell git ver) 4 | BIN = $(NAME)-$(VERSION) 5 | S3HOME = s3://download.elasticsearch.org/es2unix 6 | 7 | package: target/$(BIN) 8 | 9 | test: install 10 | bin/test 11 | 12 | install: target/$(BIN) 13 | cp target/$(BIN) ~/bin/$(NAME) 14 | 15 | release: target/$(BIN) 16 | s3c es.download put -P target/$(BIN) $(S3HOME)/$(BIN) 17 | s3c es.download cp $(S3HOME)/$(BIN) $(S3HOME)/$(NAME) 18 | 19 | clean: 20 | $(LEIN) clean 21 | 22 | target/$(BIN): 23 | mkdir -p etc 24 | echo $(VERSION) >etc/version.txt 25 | LEIN_SNAPSHOTS_IN_RELEASE=yes $(LEIN) bin 26 | 27 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # es2unix 2 | 3 | **this Repo is now Read-Only and Deprecated since elasticsearch 1.0. Use the [cat API instead](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/cat.html). Also check out https://github.com/drewr/copycat.** 4 | 5 | Elasticsearch API consumable by the command line. 6 | 7 | JSON isn't always the most convenient output, particularly on a 8 | terminal. The tabular format has stuck around for good reason. It's 9 | compact. It's line-oriented. es2unix strives to keep spaces 10 | significant so all output works with existing *NIX tools. `grep`, 11 | `sort`, & `awk` are first-class citizens here. 12 | 13 | 14 | # Install 15 | 16 | es2unix's only dependency is Java (Oracle or OpenJDK). Version 7 17 | should be preferred, but there is no functional difference with 6. 18 | Earlier versions aren't supported. 19 | 20 | curl -s download.elasticsearch.org/es2unix/es >~/bin/es 21 | chmod +x ~/bin/es 22 | 23 | You can also pin to a particular version from your provisioning tools. 24 | 25 | curl -s download.elasticsearch.org/es2unix/es-20130503595fce2 >~/bin/es 26 | 27 | # Usage 28 | 29 | The `es` command takes subcommands and a few options. It assumes it's 30 | talking to ES at its default HTTP port using `http://localhost:9200` 31 | but accepts `-u` to change that. It must be a fully qualifed URL with 32 | scheme, host, & port. 33 | 34 | You can also supply `-v`, for most commands, to print a column header. 35 | 36 | 37 | ## Version 38 | 39 | % es version 40 | es 1.0.0 41 | elasticsearch 0.21.0.Beta1 42 | 43 | 44 | ## Health 45 | 46 | % es health -v 47 | cluster status nodes data pri shards relo init unassign 48 | kluster green 2 2 3 6 0 0 0 49 | 50 | ## Count 51 | 52 | Sometimes you need a quick count to tell whether a cluster has any 53 | data and whether it's indexing. You can also supply a query. 54 | 55 | % es count 56 | 2,319,799 57 | % es count elasticsearch 58 | 3 "q=elasticsearch" 59 | % es count "john deacon" 60 | 225,839 "q=john deacon" 61 | % es count "\"saved by the bell\"" 62 | 220 "q="saved by the bell"" 63 | 64 | ## Search 65 | 66 | Not exhaustive access to the query API by any stretch, but it suffices 67 | when you need to get a glance of the data in your cluster. Searches 68 | across indices with a default query of `*:*`. 69 | 70 | % es search 71 | 1.0 wiki page 1228929 72 | 1.0 wiki page 1229142 73 | 1.0 wiki page 1229146 74 | 1.0 wiki page 1229153 75 | 1.0 wiki page 1228943 76 | 1.0 wiki page 1229155 77 | 1.0 wiki page 1228950 78 | 1.0 wiki page 1229159 79 | 1.0 wiki page 1228956 80 | 1.0 wiki page 1229160 81 | Total: 2319799 82 | 83 | Can also specify a query, like `es search \"george costanza\"`, and, 84 | possibly more interestingly, a list of fields to return. 85 | 86 | % es search -v "george costanza" title 87 | score index type id title 88 | 5.78647 wiki page 660183 George Costansa 89 | 5.78647 wiki page 273868 George Constanza 90 | 5.63803 wiki page 865781 Vandelay Industries 91 | 4.69835 wiki page 932333 Art Vandelay 92 | 4.69835 wiki page 2147975 Can't Stand Ya 93 | 4.67351 wiki page 2486208 Art vandelay 94 | 4.07630 wiki page 2147959 Costanza 95 | 3.23200 wiki page 2147971 The Costanza family 96 | 3.21007 wiki page 2147972 Costanza family 97 | 2.94863 wiki page 4946953 Santa costanza 98 | Total: 118186 99 | 100 | ## Master 101 | 102 | % es master 103 | J-erllamTOiW5WoGVUd04A 127.0.0.1 Slade, Frederick 104 | 105 | 106 | ## Indices 107 | 108 | % es indices -v 109 | status name pri rep docs size 110 | green _river 0 1 4 8068 111 | green wiki 1 1 1104894 13805525784 112 | 113 | Maybe your cluster is red and you need to know which indices are 114 | affected: 115 | 116 | % es indices | grep \^red 117 | red bb 5 0 118 | red test 4 1 218b 218 0 119 | red enron 5 0 120 | red uno 1 0 121 | 122 | ## Allocation 123 | Displays shard allocation counts across nodes 124 | 125 | % es allocation -v 126 | count ip name 127 | 12 192.168.0.24 Sage 128 | 30 x.x.x.x UNASSIGNED 129 | 130 | ## Nodes 131 | 132 | What HTTP port is `Cannonball I` listening on? Who's the master? 133 | Who's master-eligible? Who's got `data=true`? 134 | 135 | % es nodes 136 | Uv1Iy8FvR0y6_RzPXKBolg 127.0.0.1 9201 127.0.0.1 9300 d Cannonball I 137 | J-erllamTOiW5WoGVUd04A 127.0.0.1 9200 127.0.0.1 9301 * d Slade, Frederick 138 | j27iagsmQQaeIpl6yU6mCg 127.0.0.1 9203 127.0.0.1 9303 - c Georgianna Castleberry 139 | T1aFDU2BSUm748gYxjEN9w 127.0.0.1 9202 127.0.0.1 9302 d Living Tribunal 140 | 141 | If you have access to logs from all the nodes, you can run `lifecycle` 142 | to get a playback of all the node joinings and leavings with their 143 | timestamps ordered sequentially. This is much faster than combing the 144 | logs and piecing together the sequence manually. 145 | 146 | % es lifecycle /tmp/es-*/logs/elasticsearch.log 147 | 2013-02-08 13:47:15,516 Lurking Unknown INIT 0.21.0.Beta1-SNAPSHOT 148 | 2013-02-08 13:47:20,413 Lurking Unknown MASTER Lurking Unknown 149 | 2013-02-08 13:47:20,467 Lurking Unknown START 150 | 2013-02-08 13:47:36,319 Cameron Hodge INIT 0.21.0.Beta1-SNAPSHOT 151 | 2013-02-08 13:47:41,211 Lurking Unknown ADD Cameron Hodge 152 | 2013-02-08 13:47:41,223 Cameron Hodge MASTER Lurking Unknown 153 | 2013-02-08 13:47:41,278 Cameron Hodge START 154 | 2013-02-08 13:47:59,426 Armageddon INIT 0.21.0.Beta1-SNAPSHOT 155 | 2013-02-08 13:48:04,279 Lurking Unknown ADD Armageddon 156 | 2013-02-08 13:48:04,280 Cameron Hodge ADD Armageddon 157 | 2013-02-08 13:48:04,287 Armageddon MASTER Lurking Unknown 158 | 2013-02-08 13:48:04,340 Armageddon START 159 | 2013-02-08 13:48:30,333 Lurking Unknown REMOVE Armageddon 160 | 2013-02-08 13:48:30,339 Cameron Hodge REMOVE Armageddon 161 | 2013-02-08 13:48:30,362 Armageddon STOP 162 | 163 | ## Heap 164 | 165 | Heap across the cluster. 166 | 167 | % es heap | sort -rnk6 168 | XO6c2A1D 23.9mb 25138608 123.7mb 129761280 19.4% 127.0.0.1 Junkpile 169 | uVP8g9_l 94.6mb 99257976 990.7mb 1038876672 9.6% 127.0.0.1 Hammond, Jim 170 | pjbeg_k8 76.9mb 80730208 990.7mb 1038876672 7.8% 127.0.0.1 Scarlet Centurion 171 | 172 | For some quick and dirty monitoring, I like to put this in a loop. 173 | 174 | % while true; do es heap | sort -rnk6 | head -1; sleep 60; done 175 | XO6c2A1D 57.3mb 60157200 123.7mb 129761280 46.4% 127.0.0.1 Junkpile 176 | XO6c2A1D 54.7mb 57405904 123.7mb 129761280 44.2% 127.0.0.1 Junkpile 177 | XO6c2A1D 62.7mb 65834752 123.7mb 129761280 50.7% 127.0.0.1 Junkpile 178 | XO6c2A1D 56.9mb 59743504 123.7mb 129761280 46.0% 127.0.0.1 Junkpile 179 | XO6c2A1D 52.1mb 54676216 123.7mb 129761280 42.1% 127.0.0.1 Junkpile 180 | XO6c2A1D 37.1mb 38971744 123.7mb 129761280 30.0% 127.0.0.1 Junkpile 181 | XO6c2A1D 52mb 54528424 123.7mb 129761280 42.0% 127.0.0.1 Junkpile 182 | XO6c2A1D 46.5mb 48787064 123.7mb 129761280 37.6% 127.0.0.1 Junkpile 183 | 184 | This can be extremely helpful during indexing, for example. If you 185 | see a single node showing up a lot, you might have hot shard(s) there. 186 | If you see all the nodes regularly showing up with varying heap usage 187 | percentage, it's likely a healthy cluster with good shard 188 | distribution. 189 | 190 | Searching has slightly different characteristics, but you can make 191 | similarly helpful inferences. 192 | 193 | 194 | ## Ids 195 | 196 | Sometimes it's helpful to retrieve the ids of all documents in an ES 197 | index. 198 | 199 | % es ids test -v 200 | index type id 201 | test doc 1 202 | test doc 2 203 | test doc 3 204 | test doc 4 205 | 206 | 207 | ## Shards 208 | 209 | ### Node startup 210 | 211 | We've started up three nodes where we had two before. ES decided to 212 | move one shard to the third node. 213 | 214 | % es shards 215 | wiki 0 p STARTED 1160290 7.2gb 7776371641 127.0.0.1 Feline 216 | wiki 0 r STARTED 1160290 7.2gb 7776371602 127.0.0.1 Jenkins, Abner 217 | wiki 1 p RELOCATING 1159509 7.5gb 8116295811 127.0.0.1 Feline -> 127.0.0.1 Amphibius 218 | wiki 1 r STARTED 1159509 7.5gb 8116295811 127.0.0.1 Jenkins, Abner 219 | 220 | ### After turning on more replicas 221 | 222 | We set `index.number_of_replicas` to `2`, so ES is creating another 223 | copy of each primary shard. 224 | 225 | % es shards 226 | wiki 0 p STARTED 1160290 7.2gb 7776371641 127.0.0.1 Feline 227 | wiki 0 r INITIALIZING 0 100.2mb 105077522 127.0.0.1 Amphibius 228 | wiki 0 r STARTED 1160290 7.2gb 7776371602 127.0.0.1 Jenkins, Abner 229 | wiki 1 r INITIALIZING 0 120.3mb 126157581 127.0.0.1 Feline 230 | wiki 1 p STARTED 1159509 7.5gb 8116295811 127.0.0.1 Amphibius 231 | wiki 1 r STARTED 1159509 7.5gb 8116295811 127.0.0.1 Jenkins, Abner 232 | 233 | ### Single node filter by index, sort reverse by bytes 234 | 235 | You can limit the results to a substring match of an index. This 236 | filters that output's sixth column through a descending sort. 237 | 238 | % es shards wik | sort -rnk6 239 | wiki 1 r STARTED 2.7gb 2980767835 276016 127.0.0.1 Namora 240 | wiki 0 r STARTED 2.7gb 2953985585 276441 127.0.0.1 Namora 241 | wiki 1 p STARTED 2.7gb 2909784771 276016 127.0.0.1 Android Man 242 | wiki 0 p STARTED 2.6gb 2846741702 276441 127.0.0.1 Android Man 243 | 244 | ### Normal three-node cluster operation 245 | 246 | Add column names. 247 | 248 | % es shards -v 249 | index shard pri/rep state docs size bytes ip node 250 | wiki 0 p STARTED 1160290 7.2gb 7776371641 127.0.0.1 Feline 251 | wiki 0 r INITIALIZING 0 3.1gb 3384641066 127.0.0.1 Amphibius 252 | wiki 0 r STARTED 1160290 7.2gb 7776371602 127.0.0.1 Jenkins, Abner 253 | wiki 1 r INITIALIZING 0 3.7gb 4029041251 127.0.0.1 Feline 254 | wiki 1 p STARTED 1159509 7.5gb 8116295811 127.0.0.1 Amphibius 255 | wiki 1 r STARTED 1159509 7.5gb 8116295811 127.0.0.1 Jenkins, Abner 256 | 257 | # Contributing 258 | 259 | es2unix is written in Clojure. You'll need leiningen 2.0+ to build. 260 | 261 | % make package 262 | 263 | # License 264 | 265 | This software is licensed under the Apache 2 license, quoted below. 266 | 267 | Copyright 2012-2013 ElasticSearch 268 | 269 | Licensed under the Apache License, Version 2.0 (the "License"); you may not 270 | use this file except in compliance with the License. You may obtain a copy of 271 | the License at 272 | 273 | http://www.apache.org/licenses/LICENSE-2.0 274 | 275 | Unless required by applicable law or agreed to in writing, software 276 | distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 277 | WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 278 | License for the specific language governing permissions and limitations under 279 | the License. 280 | -------------------------------------------------------------------------------- /bin/es: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | exec java -client \ 4 | -XX:+TieredCompilation \ 5 | -XX:TieredStopAtLevel=1 \ 6 | -Xbootclasspath/a:target/es.jar \ 7 | es.main "$@" 8 | -------------------------------------------------------------------------------- /bin/release: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env zsh 2 | 3 | rel=$1 4 | new=$2 5 | 6 | if [[ -z $rel && -z $new ]]; then 7 | echo $0 RELVER NEWVER 8 | exit 1 9 | fi 10 | 11 | echo $rel >etc/version.txt 12 | make install 13 | bin/test || exit 1 14 | 15 | git commit -a -m "v${rel}" 16 | git tag -f -am v${rel} v${rel} 17 | make deploy S3CREDS=~/.s3cfg.es.download 18 | echo $new >etc/version.txt 19 | git commit -a -m "v${new}" 20 | -------------------------------------------------------------------------------- /bin/save: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | dir=test/output/`dirname "$1"` 4 | echo "\"$dir\"" 5 | [ -d "$dir" ] || mkdir -p "$dir" 6 | curl -s localhost:9200/$1 | json_xs | tee "test/output/$1.json" 7 | -------------------------------------------------------------------------------- /bin/test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env zsh 2 | 3 | if curl -s localhost:9200 >/dev/null; then 4 | for cmd in `~/bin/es help 2>&1 | egrep '^ [a-z]'`; do 5 | echo '===' $cmd 6 | ~/bin/es -v $cmd 7 | done 8 | ~/bin/es 9 | else 10 | echo no ES running for sanity check 11 | fi 12 | -------------------------------------------------------------------------------- /etc/commons-logging.properties: -------------------------------------------------------------------------------- 1 | org.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JLogger 2 | -------------------------------------------------------------------------------- /etc/log4j.properties: -------------------------------------------------------------------------------- 1 | log4j.rootLogger=INFO 2 | log4j.logger.org.apache.http=FATAL 3 | -------------------------------------------------------------------------------- /hs/Es2Unix/Health.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE OverloadedStrings #-} 2 | 3 | module Es2Unix.Health where 4 | 5 | import Control.Applicative 6 | import Control.Monad 7 | import Data.Aeson 8 | 9 | data Health = 10 | Health { getClusterName :: String 11 | , getStatus :: String 12 | , getNumberOfNodes :: Integer 13 | , getNumberOfDataNodes :: Integer 14 | , getActivePrimaryShards :: Integer 15 | , getActiveShards :: Integer 16 | , getRelocatingShards :: Integer 17 | , getInitializingShards :: Integer 18 | , getUnassignedShards :: Integer 19 | } deriving (Show) 20 | 21 | instance FromJSON Health where 22 | parseJSON (Object v) = Health <$> 23 | (v .: "cluster_name") <*> 24 | (v .: "status") <*> 25 | (v .: "number_of_nodes") <*> 26 | (v .: "number_of_data_nodes") <*> 27 | (v .: "active_primary_shards") <*> 28 | (v .: "active_shards") <*> 29 | (v .: "relocating_shards") <*> 30 | (v .: "initializing_shards") <*> 31 | (v .: "unassigned_shards") 32 | parseJSON _ = mzero 33 | 34 | -------------------------------------------------------------------------------- /hs/Es2Unix/Indices.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE OverloadedStrings #-} 2 | 3 | module Es2Unix.Indices where 4 | 5 | import Control.Monad 6 | import Control.Applicative 7 | import Data.Aeson 8 | import Data.Map (Map, toList) 9 | import Data.Text (Text, unpack) 10 | import qualified Data.ByteString.Lazy.Char8 as BS 11 | 12 | newtype Indices = Indices (Map String IndexHealth) 13 | deriving (Show) 14 | 15 | data Health = Health 16 | { status :: Text 17 | , indices :: Indices 18 | } deriving (Show) 19 | 20 | data IndexHealth = IndexHealth 21 | { indexStatus :: Text 22 | } deriving (Show) 23 | 24 | instance FromJSON Indices where 25 | parseJSON v = Indices <$> parseJSON v 26 | 27 | instance FromJSON Health where 28 | parseJSON j = do 29 | o <- parseJSON j 30 | Health <$> 31 | o .: "status" <*> 32 | o .: "indices" 33 | 34 | instance FromJSON IndexHealth where 35 | parseJSON j = do 36 | o <- parseJSON j 37 | IndexHealth <$> o .: "status" 38 | 39 | getIndices :: BS.ByteString -> Maybe Indices 40 | getIndices j = 41 | case decode j :: Maybe Health of 42 | (Just health) -> Just (indices health) 43 | Nothing -> Nothing 44 | 45 | p :: (String, IndexHealth) -> IO () 46 | p (k, ih) = putStrLn $ unpack (indexStatus ih) ++ " " ++ k 47 | 48 | main :: IO () 49 | main = do 50 | json <- BS.getContents 51 | case getIndices json of 52 | Just (Indices m) -> mapM_ p (toList m) 53 | Nothing -> putStrLn "invalid json" 54 | 55 | -------------------------------------------------------------------------------- /hs/es.hs: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env runhaskell 2 | 3 | import Data.Aeson 4 | import qualified Data.ByteString.Lazy.Char8 as BS 5 | import Network.HTTP (simpleHTTP, getRequest, getResponseBody) 6 | import Es2Unix.Health 7 | 8 | main :: IO () 9 | main = do 10 | json <- get "http://localhost:9200/_cluster/health" 11 | let (Just health) = decode (BS.pack json) :: Maybe Health 12 | putStrLn $ unwords [ 13 | getClusterName health 14 | ,getStatus health 15 | ,show $ getNumberOfNodes health 16 | ,show $ getNumberOfDataNodes health 17 | ,show $ getActivePrimaryShards health 18 | ,show $ getActiveShards health 19 | ,show $ getRelocatingShards health 20 | ,show $ getInitializingShards health 21 | ,show $ getUnassignedShards health 22 | ] 23 | 24 | get :: String -> IO String 25 | get url = getResponseBody =<< simpleHTTP (getRequest url) 26 | -------------------------------------------------------------------------------- /project.clj: -------------------------------------------------------------------------------- 1 | (defproject org.elasticsearch/es 2 | (try (-> "etc/version.txt" slurp .trim) 3 | (catch java.io.FileNotFoundException _ "0.0.1")) 4 | :description "es2unix" 5 | :resource-paths ["etc" "resources"] 6 | :url "http://elasticsearch.org/" 7 | :license {:name "Apache License, Version 2.0" 8 | :url "http://www.apache.org/licenses/LICENSE-2.0.html"} 9 | :dependencies [[org.clojure/clojure "1.6.0"] 10 | [org.clojure/tools.cli "0.2.2"] 11 | [cheshire "5.0.2"] 12 | [clj-http "0.6.4"] 13 | [log4j/log4j "1.2.17"] 14 | [bultitude "0.2.0"] 15 | [slingshot "0.10.3"] 16 | [com.google.guava/guava "14.0-rc1"]] 17 | :plugins [[lein-bin "0.3.0"]] 18 | :main es.main 19 | :uberjar-name "es.jar" 20 | :jvm-opts ["-XX:TieredStopAtLevel=1" 21 | "-XX:+TieredCompilation"] 22 | :bin {:bootclasspath :yes!}) 23 | -------------------------------------------------------------------------------- /src/es/command.clj: -------------------------------------------------------------------------------- 1 | (ns es.command 2 | (:require [es.command.allocation] 3 | [es.command.count] 4 | [es.command.lifecycle] 5 | [es.command.health] 6 | [es.command.heap] 7 | [es.command.ids] 8 | [es.command.indices] 9 | [es.command.master] 10 | [es.command.nodes] 11 | [es.command.shards] 12 | [es.command.search] 13 | [es.command.version])) 14 | 15 | (def available 16 | ['allocation 17 | 'count 18 | 'lifecycle 19 | 'health 20 | 'heap 21 | 'ids 22 | 'indices 23 | 'master 24 | 'nodes 25 | 'search 26 | 'shards 27 | 'version]) 28 | -------------------------------------------------------------------------------- /src/es/command/allocation.clj: -------------------------------------------------------------------------------- 1 | (ns es.command.allocation 2 | (:require [es.data.cluster :as data] 3 | [es.data.nodes :as nodes] 4 | [es.format.network :refer [parse-addr]] 5 | [clojure.set :refer [rename-keys]])) 6 | 7 | (def cols 8 | ['count 9 | 'ip 10 | 'name]) 11 | 12 | (defn allocation [http args {:keys [verbose]}] 13 | (concat 14 | (if verbose 15 | [(map str cols)]) 16 | (let [shards (for [[name idx] (data/routing http) 17 | [shardnum shard] (:shards idx) 18 | s shard] 19 | (:node s)) 20 | names-to-ips (into {} (map (fn [[k v]] 21 | [(:name v) 22 | (-> v 23 | :transport_address 24 | parse-addr 25 | :ip)]) 26 | (nodes/nodes http))) 27 | nodes-to-names (into {} (map (fn [[k v]] [(name k) (:name v)]) 28 | (nodes/nodes http))) 29 | freq (frequencies shards) 30 | allocations (rename-keys freq (merge nodes-to-names 31 | {nil "UNASSIGNED"})) 32 | allocations (doall (for [[node shardnum] allocations] 33 | [shardnum 34 | (get names-to-ips node "x.x.x.x") 35 | node]))] 36 | allocations))) 37 | -------------------------------------------------------------------------------- /src/es/command/count.clj: -------------------------------------------------------------------------------- 1 | (ns es.command.count 2 | (:refer-clojure :exclude [count]) 3 | (:require [es.data.cluster :as cluster] 4 | [es.util.time :as time] 5 | [es.util :as util])) 6 | 7 | (defn count [http args {:keys [verbose]}] 8 | (let [[q] args 9 | res (if q 10 | (cluster/count http q) 11 | (cluster/count http)) 12 | failed (or (get-in res [:_shards :failed]) 99999) 13 | out (util/commafy (:count res)) 14 | out (if q (format "%s \"%s\"" out q) out) 15 | out (if (pos? failed) 16 | (format "%s ...with %d failed shards!" out failed) 17 | out)] 18 | [(cons (time/hms) [out])])) 19 | -------------------------------------------------------------------------------- /src/es/command/health.clj: -------------------------------------------------------------------------------- 1 | (ns es.command.health 2 | (:require [es.data.cluster :as cluster] 3 | [es.util.time :as time])) 4 | 5 | (def cols 6 | [['cluster :cluster_name] 7 | ['status :status] 8 | ['nodes :number_of_nodes] 9 | ['data :number_of_data_nodes] 10 | ['pri :active_primary_shards] 11 | ['shards :active_shards] 12 | ['relo :relocating_shards] 13 | ['init :initializing_shards] 14 | ['unassign :unassigned_shards]]) 15 | 16 | (defn health [http args {:keys [verbose]}] 17 | (concat 18 | (if verbose 19 | [(cons "time" (map (comp name first) cols))]) 20 | (let [res (cluster/health http) 21 | vals* (apply juxt (map second cols))] 22 | [(cons (time/hms) (vals* res))]))) 23 | -------------------------------------------------------------------------------- /src/es/command/heap.clj: -------------------------------------------------------------------------------- 1 | (ns es.command.heap 2 | (:require [es.data.cluster :as cluster] 3 | [es.format.network :refer [ip]] 4 | [es.util :refer [substr]])) 5 | 6 | (def cols 7 | ['id 8 | 'heap 9 | 'heap 10 | 'max 11 | 'max 12 | 'ratio 13 | 'ip 14 | 'name]) 15 | 16 | (defn heap [http args opts] 17 | (concat 18 | (if (:verbose opts) 19 | [cols]) 20 | (for [[id node] (cluster/mem http)] 21 | [(substr (name id) 8) 22 | {:val (:heap_used node) :just :->} 23 | (:heap_used_in_bytes node) 24 | {:val (:heap_max node) :just :->} 25 | (:heap_max_in_bytes node) 26 | {:val (:heap_used_percent node) :just :->} 27 | (-> node :transport_address ip) 28 | (-> node :name)]))) 29 | -------------------------------------------------------------------------------- /src/es/command/ids.clj: -------------------------------------------------------------------------------- 1 | (ns es.command.ids 2 | (:require [es.data.search :as search])) 3 | 4 | ;; Intentionally does not use tabler, since that causes OOMEs for 5 | ;; large result sets 6 | (defn ids [http args {:keys [verbose]}] 7 | (when verbose 8 | (println "index type id")) 9 | (if-let [idx (first args)] 10 | (let [estype (second args)] 11 | (doall (map #(println (:_index %) (:_type %) (:_id %)) 12 | (search/scroll http idx estype "*:*" [] 100))) 13 | ;; Return something that won't cause the output formatter to 14 | ;; blow up 15 | []) 16 | (println "usage: es ids INDEX [TYPE]"))) 17 | -------------------------------------------------------------------------------- /src/es/command/indices.clj: -------------------------------------------------------------------------------- 1 | (ns es.command.indices 2 | (:require [es.data.indices :as idx] 3 | [es.format.table :as table] 4 | [es.util :refer [maybe-get-in]])) 5 | 6 | (def cols 7 | ['status 8 | 'name 9 | 'pri 10 | 'rep 11 | 'size 12 | 'bytes 13 | 'docs]) 14 | 15 | (defn indices [http args {:keys [verbose]}] 16 | (concat 17 | (if verbose 18 | [(map str cols)]) 19 | (for [[nam data] (idx/indices http args)] 20 | [(maybe-get-in data :health :status) 21 | (name nam) 22 | (-> data :health :active_primary_shards) 23 | (maybe-get-in data :health :number_of_replicas) 24 | (table/make-cell 25 | {:val (maybe-get-in data :stats :total :store :size) 26 | :just :->}) 27 | (maybe-get-in data :stats :total :store :size_in_bytes) 28 | (maybe-get-in data :stats :primaries :docs :count)]))) 29 | -------------------------------------------------------------------------------- /src/es/command/lifecycle.clj: -------------------------------------------------------------------------------- 1 | (ns es.command.lifecycle 2 | (:require [clojure.java.io :as io])) 3 | 4 | (def pat-pre 5 | (str "^\\[([^]]+)\\]" ;; timestamp 6 | "\\[[^]]+\\]" ;; log level 7 | "\\[(?:node|transport|cluster\\.service)\\s*\\] " ;; package 8 | "\\[([^]]+)\\] " ;; node name 9 | )) 10 | 11 | (def pat-post 12 | "") 13 | 14 | (def op-pats 15 | [["\\{([^}]+)\\}\\[[^]]+\\]: initializing " 16 | 'INIT 17 | [:timestamp :me :version] 18 | [:timestamp :me :op :version]] 19 | [".* publish_address \\{inet\\[.*?/([^]]+)\\]\\}" 20 | 'BIND 21 | [:timestamp :me :ip] 22 | [:timestamp :me :op :ip]] 23 | ["\\{([^}]+)\\}\\[[^]]+\\]: started" 24 | 'START 25 | [:timestamp :me :version] 26 | [:timestamp :me :op :_]] 27 | ["\\{([^}]+)\\}\\[[^]]+\\]: stopped" 28 | 'STOP 29 | [:timestamp :me :version] 30 | [:timestamp :me :op :_]] 31 | ["(new|detected)_master \\[([^]]+)\\]\\[[^]]+\\]\\[inet\\[.*?/([^]]+)\\]" 32 | 'MASTER 33 | [:timestamp :me :_ :her-name :her-ip] 34 | [:timestamp :me :op :her-name]] 35 | ["added \\{\\[([^]]+)\\]\\[[^]]+\\]\\[inet\\[.*?/([^]]+)\\]" 36 | 'ADD 37 | [:timestamp :me :her-name :her-ip] 38 | [:timestamp :me :op :her-name]] 39 | ["removed \\{\\[([^]]+)\\]\\[[^]]+\\]\\[inet\\[.*?/([^]]+)\\]" 40 | 'REMOVE 41 | [:timestamp :me :her-name :her-ip] 42 | [:timestamp :me :op :her-name]]]) 43 | 44 | (defn match [pats line] 45 | (let [f (fn [[pat op ks output]] 46 | (if-let [matched (re-find (re-pattern 47 | (str pat-pre pat pat-post)) line)] 48 | (merge {:op op 49 | :output output} 50 | (zipmap ks (rest matched)))))] 51 | (->> pats 52 | (map f) 53 | (some identity)))) 54 | 55 | (defn ops [rdr] 56 | (->> (line-seq rdr) 57 | (map #(match op-pats %)) 58 | (filter identity))) 59 | 60 | (defn lifecycle [_ files opts] 61 | (->> (for [f files 62 | op (ops (io/reader f))] 63 | ((apply juxt (:output op)) op)) 64 | sort)) 65 | -------------------------------------------------------------------------------- /src/es/command/master.clj: -------------------------------------------------------------------------------- 1 | (ns es.command.master 2 | (:require [es.data.nodes :as nodes] 3 | [es.format.network :refer [ip]])) 4 | 5 | (defn master [http args opts] 6 | (let [res (nodes/master http)] 7 | (or 8 | (:http-error res) 9 | (let [id (:master_node res) 10 | m (get (:nodes res) (keyword id))] 11 | [[id (ip (:transport_address m)) (:name m)]])))) 12 | -------------------------------------------------------------------------------- /src/es/command/nodes.clj: -------------------------------------------------------------------------------- 1 | (ns es.command.nodes 2 | (:require [es.data.cluster :as cluster] 3 | [es.data.nodes :as nodes] 4 | [es.format.network :refer [parse-addr]])) 5 | 6 | (def cols 7 | ['id 8 | 'http-ip 9 | 'port 10 | 'tran-ip 11 | 'tran-port 12 | 'jdk 13 | 'heap 14 | 'uptime 15 | 'data/client 16 | 'master? 17 | 'name]) 18 | 19 | (defn nodes [http args {:keys [verbose]}] 20 | (concat 21 | (if verbose 22 | [(map str cols)]) 23 | (let [nodes (nodes/nodes http) 24 | mem (cluster/mem http) 25 | mast (nodes/master-id http)] 26 | (for [[id node] nodes] 27 | (let [httpaddr (-> node :http_address parse-addr) 28 | tranaddr (-> node :transport_address parse-addr) 29 | uptime (int 30 | (/ 31 | (- (System/currentTimeMillis) 32 | (or (-> node :jvm :start_time) 33 | (System/currentTimeMillis))) 34 | 1000)) 35 | I-am-master? (= (name id) mast) 36 | master? (if (nodes/master-eligible? node) 37 | (if I-am-master? 38 | "*" 39 | " ") 40 | "-") 41 | data? (if (nodes/client? node) 42 | "c" 43 | (if (nodes/store-data? node) 44 | "d" 45 | "-"))] 46 | [(name id) 47 | (:ip httpaddr) 48 | (:port httpaddr) 49 | (:ip tranaddr) 50 | (:port tranaddr) 51 | (-> node :jvm :version) 52 | {:val (-> mem id :heap_used_percent) :just :->} 53 | uptime 54 | data? 55 | master? 56 | (:name node)]))))) 57 | -------------------------------------------------------------------------------- /src/es/command/search.clj: -------------------------------------------------------------------------------- 1 | (ns es.command.search 2 | (:require [es.data.search :as search] 3 | [es.util :refer [substr]])) 4 | 5 | (def max-width 6 | 20) 7 | 8 | (defn search [http args opts] 9 | (let [[q & fields] args 10 | resp (if q 11 | (search/search http q fields) 12 | (search/search http)) 13 | total (get-in resp [:hits :total]) 14 | header [(concat 15 | ['score 16 | 'index 17 | 'type 18 | 'id] 19 | (if (seq fields) 20 | fields))]] 21 | (concat 22 | (if (:verbose opts) header) 23 | (for [hit (:hits (:hits resp))] 24 | (concat 25 | [(-> (:_score hit) (substr 7)) 26 | (:_index hit) 27 | (:_type hit) 28 | (:_id hit)] 29 | (if (:fields hit) 30 | (for [f fields] 31 | (-> hit 32 | (get-in [:fields (keyword f)]) 33 | (substr max-width) 34 | (.replaceAll "\n" "") 35 | .trim))))) 36 | [(concat 37 | [" Total:" {:val total :just :<-}] 38 | (repeat (+ 2 (count fields)) " "))]))) 39 | -------------------------------------------------------------------------------- /src/es/command/shards.clj: -------------------------------------------------------------------------------- 1 | (ns es.command.shards 2 | (:require [es.data.cluster :as cluster] 3 | [es.data.indices :as indices] 4 | [es.data.nodes :as nodes] 5 | [es.data.replica :as replica] 6 | [es.format.network :refer [ip]] 7 | [es.format.table :refer [make-cell]])) 8 | 9 | (def cols 10 | ['index 11 | 'shard 12 | 'pri/rep 13 | 'state 14 | 'docs 15 | 'size 16 | 'bytes 17 | 'ip 18 | 'node]) 19 | 20 | (defn name-maybe-relocating [sh] 21 | (if (:relocating_node sh) 22 | (format "%s -> %s %s" 23 | (get-in sh [:node :name]) 24 | (ip (get-in sh [:relocating_node :transport_address])) 25 | (get-in sh [:relocating_node :name])) 26 | (get-in sh [:node :name]))) 27 | 28 | (defn run [state stats indices] 29 | (for [sh (cluster/shards state indices)] 30 | (let [routing (merge sh {:node (get-in sh [:node :id])}) 31 | k (replica/make-key routing) 32 | shstat (stats k)] 33 | [(sh :index) 34 | (sh :shard) 35 | (if (replica/primary? sh) "p" "r") 36 | (sh :state) 37 | (get-in shstat [:docs :count]) 38 | {:val (get-in shstat [:store :size]) :just :->} 39 | (get-in shstat [:store :size_in_bytes]) 40 | (ip (get-in sh [:node :transport_address])) 41 | (name-maybe-relocating sh)]))) 42 | 43 | (defn shards [http args {:keys [verbose]}] 44 | (concat 45 | (if verbose 46 | [cols]) 47 | (run (cluster/get-state http) 48 | (-> http 49 | cluster/get-shard-stats 50 | cluster/shard-stats) 51 | args))) 52 | -------------------------------------------------------------------------------- /src/es/command/version.clj: -------------------------------------------------------------------------------- 1 | (ns es.command.version 2 | (:require [clojure.java.io :as io])) 3 | 4 | (defn version* [] 5 | (-> "version.txt" io/resource slurp .trim)) 6 | 7 | (defn esver [http] 8 | (get-in (http) [:version :number])) 9 | 10 | (defn version [http args opts] 11 | (let [ver (version*) 12 | esver (or (esver http) 13 | (format "not running at %s" (:url opts)))] 14 | [["es" ver] 15 | ["elasticsearch" esver]])) 16 | -------------------------------------------------------------------------------- /src/es/data/cluster.clj: -------------------------------------------------------------------------------- 1 | (ns es.data.cluster 2 | (:refer-clojure :exclude [count]) 3 | (:require [es.data.replica :as replica] 4 | [es.data.nodes :as nodes] 5 | [es.format.uri :as uri] 6 | [es.util :as util])) 7 | 8 | (defn health 9 | ([http] 10 | (http "/_cluster/health")) 11 | ([http indices] 12 | (let [healths (http "/_cluster/health?level=indices")] 13 | (->> (for [[nam data] (:indices healths)] 14 | (if (util/match-any? (name nam) indices) 15 | [nam data])) 16 | (filter identity) 17 | (into {}))))) 18 | 19 | (defn get-state [http] 20 | (http "/_cluster/state?filter_metadata=1")) 21 | 22 | (defn get-shard-stats [http] 23 | (http "/_stats?level=shards&all=1")) 24 | 25 | (defn shard-stats 26 | ([stats] 27 | (shard-stats stats [])) 28 | ([stats indices] 29 | (->> 30 | (for [[idxname index] (get-in stats [:indices]) 31 | [shardid shards] (get index :shards) 32 | replica shards] 33 | (let [routing {:index idxname 34 | :shard shardid 35 | :primary (get-in replica [:routing :primary]) 36 | :node (get-in replica [:routing :node])}] 37 | (if (replica/maybe routing indices) 38 | [(replica/make-key routing) replica]))) 39 | (filter identity) 40 | (into {})))) 41 | 42 | (defn shards 43 | ([state] 44 | (shards state {} [])) 45 | ([state indices] 46 | (let [nodes (:nodes state)] 47 | ( ->> 48 | (for [[idxname index] (get-in state [:routing_table :indices]) 49 | [_ shard] (get index :shards) 50 | replica shard] 51 | (if-let [rep (replica/maybe replica indices)] 52 | (let [node-id (:node rep)] 53 | (-> rep 54 | (assoc-in [:key] (replica/make-key rep)) 55 | (update-in [:node] 56 | #(nodes (keyword %))) 57 | (assoc-in [:node :id] node-id) 58 | (update-in [:relocating_node] 59 | #(nodes (keyword %))))))) 60 | (filter identity))))) 61 | 62 | (defn routing 63 | [http] 64 | (let [st (get-state http)] 65 | (for [index (-> st :routing_table :indices)] 66 | index))) 67 | 68 | (defn count 69 | ([http] 70 | (count http "*:*")) 71 | ([http query] 72 | (http (str "/_count?q=" (uri/encode query))))) 73 | 74 | (defn flaggable-nodes [http path flags] 75 | (let [path (str path "?" (uri/query-flags flags))] 76 | (http path))) 77 | 78 | (defn stats [http & flags] 79 | (flaggable-nodes http "/_nodes/stats" flags)) 80 | 81 | (defn info [http & flags] 82 | (flaggable-nodes http "/_nodes" flags)) 83 | 84 | (defn nodes [http & flags] 85 | (util/merge-transpose 86 | {:stats (:nodes (apply stats http flags))} 87 | {:info (:nodes (apply info http flags))})) 88 | 89 | (defn mem [http] 90 | (->> (for [[id node] (nodes http :jvm)] 91 | (let [stat (get-in node [:stats :jvm :mem]) 92 | info (get-in node [:info :jvm :mem])] 93 | [id (merge 94 | (nodes/mem stat info) 95 | (select-keys (:info node) [:name :transport_address]))])) 96 | (into {}))) 97 | -------------------------------------------------------------------------------- /src/es/data/indices.clj: -------------------------------------------------------------------------------- 1 | (ns es.data.indices 2 | (:require [es.data.cluster :as cluster] 3 | [es.util :as util])) 4 | 5 | (defn index-slice 6 | ([http endpoint indices] 7 | (let [lst (util/comma-list indices) 8 | lst (if (pos? (count lst)) (str "/" lst) "")] 9 | (http (str lst endpoint))))) 10 | 11 | (defn stats 12 | ([http] 13 | (stats http [])) 14 | ([http indices] 15 | (index-slice http "/_stats" indices))) 16 | 17 | (defn indices 18 | ([http] 19 | (indices http [])) 20 | ([http indices] 21 | (util/merge-transpose 22 | {:health (cluster/health http indices)} 23 | {:stats (get-in (stats http indices) [:indices])}))) 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/es/data/nodes.clj: -------------------------------------------------------------------------------- 1 | (ns es.data.nodes 2 | (:refer-clojure :exclude [false? true? name]) 3 | (:require [es.http :as http] 4 | [es.util.math :as math])) 5 | 6 | (def defaults 7 | {:client false 8 | :data true 9 | :master true}) 10 | 11 | (defn nodes [http] 12 | (-> "/_nodes?all" http :nodes)) 13 | 14 | (defn stats 15 | ([http] 16 | (-> "/_nodes/stats?all" http :nodes)) 17 | ([http id] 18 | (-> (format "/_nodes/%s/stats?all" 19 | (clojure.core/name id)) http :nodes id))) 20 | 21 | (defn master [http] 22 | (http 23 | (str "/_cluster/state?" 24 | "filter_metadata=1&" 25 | "filter_routing_table=1&" 26 | "filter_indices=1"))) 27 | 28 | (defn true? [attr] 29 | (= attr "true")) 30 | 31 | (defn false? [attr] 32 | (not (true? attr))) 33 | 34 | (defn true-attr? [attrs attr] 35 | (if attrs 36 | (if (attrs attr) 37 | (true? (attrs attr)) 38 | (defaults attr)) 39 | (defaults attr))) 40 | 41 | (defn store-data? [node] 42 | (true-attr? (:attributes node) :data)) 43 | 44 | (defn client? [node] 45 | (true-attr? (:attributes node) :client)) 46 | 47 | (defn master-eligible? [node] 48 | (if (client? node) 49 | false 50 | (true-attr? (:attributes node) :master))) 51 | 52 | (defn master-id [url] 53 | (:master_node (master url))) 54 | 55 | (defn node [http id] 56 | (let [nodes (nodes http) 57 | id (keyword id)] 58 | (nodes id))) 59 | 60 | (defn mem [mem-stat mem-info] 61 | (let [used (:heap_used_in_bytes mem-stat) 62 | max (:heap_max_in_bytes mem-info)] 63 | (merge 64 | mem-stat 65 | mem-info 66 | {:heap_used_percent (math/percent used max)}))) 67 | -------------------------------------------------------------------------------- /src/es/data/replica.clj: -------------------------------------------------------------------------------- 1 | (ns es.data.replica 2 | (:require [es.util :as util] 3 | [slingshot.slingshot :refer [throw+]])) 4 | 5 | (defn maybe 6 | "Look for matches in indices for the :index in the replica. It 7 | could be in :routing depending on the context." 8 | ([rep indices] 9 | (let [s (or (get-in rep [:routing :index]) 10 | (:index rep) 11 | (throw+ 12 | {:type ::error 13 | :msg (with-out-str 14 | (print "replica ") 15 | (prn rep) 16 | (print " didn't have any routing when matching ") 17 | (prn indices))}))] 18 | (if (util/match-any? s indices) 19 | rep)))) 20 | 21 | (defn primary? [replica] 22 | (if (contains? replica :primary) 23 | (:primary replica) 24 | (if-let [routing (-> replica :routing)] 25 | (-> routing :primary) 26 | (throw+ 27 | {:type ::error 28 | :msg (with-out-str 29 | (println "replica doesn't have routing info") 30 | (prn replica))})))) 31 | 32 | (defn make-key [routing] 33 | (let [kw (fn [x] 34 | (cond 35 | (keyword? x) x 36 | (string? x) (keyword x) 37 | (number? x) (keyword (str x)) 38 | :else x)) 39 | gets (juxt :index :shard :primary :node)] 40 | (->> routing gets (map kw) vec))) 41 | -------------------------------------------------------------------------------- /src/es/data/search.clj: -------------------------------------------------------------------------------- 1 | (ns es.data.search 2 | (:require [cheshire.core :as json] 3 | [es.format.uri :as uri] 4 | [es.util :refer [commafy]])) 5 | 6 | (defn field-list [fields] 7 | (->> fields 8 | (map str) 9 | (map uri/encode) 10 | (interpose ",") 11 | (apply str))) 12 | 13 | (defn search 14 | ([http] 15 | (search http "*:*" [])) 16 | ([http query fields] 17 | (http (str "/_search?q=" (uri/encode query) 18 | "&fields=" (field-list fields))))) 19 | 20 | (defn- scroll-fn 21 | "Private scroll function meant for interation through scrolling queries" 22 | [http sid fields] 23 | (lazy-seq 24 | (let [resp (http (str "/_search/scroll?search_type=scan&" 25 | "scroll=5m&scroll_id=" sid)) 26 | new-sid (:_scroll_id resp)] 27 | (when-let [hits (seq (-> resp :hits :hits))] 28 | (concat hits (scroll-fn http new-sid fields)))))) 29 | 30 | (defn scroll 31 | "General purpose scrolling method" 32 | ([http] 33 | (scroll nil nil "*:*" [] 100)) 34 | ([http idx type query fields size] 35 | (let [resp (http (str (when idx (str "/" idx)) 36 | (when type (str "/" type)) 37 | "/_search?search_type=scan&fields=" 38 | (field-list fields) 39 | "&scroll=5m&size=" size)) 40 | sid (:_scroll_id resp)] 41 | (concat (-> resp :hits :hits) 42 | (scroll-fn http sid fields))))) 43 | -------------------------------------------------------------------------------- /src/es/format/error.clj: -------------------------------------------------------------------------------- 1 | (ns es.format.error 2 | (:import (com.google.common.base Throwables))) 3 | 4 | (def sep (apply str (repeat 72 "-"))) 5 | 6 | (defn stack-trace 7 | ([thrown] 8 | (with-out-str 9 | (println sep) 10 | (print (Throwables/getStackTraceAsString thrown)) 11 | (print sep)))) 12 | -------------------------------------------------------------------------------- /src/es/format/network.clj: -------------------------------------------------------------------------------- 1 | (ns es.format.network) 2 | 3 | (defn parse-addr [addr] 4 | (when addr 5 | (let [[_ proto host ip port] 6 | (re-find #"(.*?)\[([^/]*)/([0-9a-f.:]+):([0-9]+)\]" addr)] 7 | {:proto proto 8 | :ip ip 9 | :port port 10 | :host host}))) 11 | 12 | (defn proto [addr] 13 | (:proto (parse-addr addr))) 14 | 15 | (defn host [addr] 16 | (:host (parse-addr addr))) 17 | 18 | (defn ip [addr] 19 | (:ip (parse-addr addr))) 20 | 21 | (defn port [addr] 22 | (:port (parse-addr addr))) 23 | -------------------------------------------------------------------------------- /src/es/format/table.clj: -------------------------------------------------------------------------------- 1 | (ns es.format.table) 2 | 3 | (defrecord Cell [val just width]) 4 | 5 | (defrecord Row [widths cells]) 6 | 7 | (defrecord Table [widths rows]) 8 | 9 | (def default-cell-value 10 | " ") 11 | 12 | (defn cell? [x] 13 | (= Cell (type x))) 14 | 15 | (defn justify [cell] 16 | (condp #(= (type %2) %1) cell 17 | Integer :-> 18 | Long :-> 19 | clojure.lang.BigInt :-> 20 | :<-)) 21 | 22 | (defn getn [m k not-found] 23 | (if-let [v (get m k)] 24 | v 25 | not-found)) 26 | 27 | (defn make-cell [x] 28 | (let [count* #(count (str (or % " "))) 29 | width (if (map? x) 30 | (:width x (count* (:val x))) 31 | (count* x))] 32 | (if (map? x) 33 | (Cell. (getn x :val default-cell-value) 34 | (:just x (justify (:val x))) 35 | width) 36 | (Cell. (or x default-cell-value) (justify x) width)))) 37 | 38 | (defn make-row [r] 39 | (let [cells (map make-cell r) 40 | widths (->> cells 41 | (map-indexed 42 | (fn [i cell] (sorted-map i (:width cell)))) 43 | (apply merge))] 44 | (Row. widths cells))) 45 | 46 | (defn make-table [rows] 47 | (let [rows (map make-row rows) 48 | widths (apply merge-with max (map :widths rows))] 49 | (Table. widths rows))) 50 | 51 | (defn fmt [sep table] 52 | (let [widths (-> table :widths vals) 53 | aligns (->> (-> table :rows last) 54 | :cells 55 | (map :just) 56 | (map {:<- "-" 57 | :-> ""}))] 58 | (->> [(repeat (count widths) "%") 59 | aligns 60 | widths 61 | (repeat (count widths) "s")] 62 | (apply map str) 63 | (interpose sep)))) 64 | 65 | (defn strings [sep data] 66 | (let [table (make-table data) 67 | fmt (apply str (fmt sep table)) 68 | values (for [row (:rows table)] 69 | (map :val (:cells row))) 70 | _ (when (not (= (count (first values)) 71 | (count (.split fmt " ")))) 72 | (throw (Exception. (with-out-str 73 | (println "fmt string") 74 | (prn fmt) 75 | (println "and values seqs") 76 | (prn values) 77 | (println "are different lengths")))))] 78 | (map (partial apply format fmt) values))) 79 | 80 | (defn dispatch [{:keys [output] :as opts} data] 81 | (keyword output)) 82 | 83 | (defmulti tabler 84 | "Return " 85 | dispatch) 86 | 87 | (defmethod tabler :default [opts data] 88 | "no output format") 89 | 90 | (defmethod tabler :raw [opts data] 91 | (when (seq data) 92 | (doseq [l (strings " " data)] 93 | (println l)))) 94 | -------------------------------------------------------------------------------- /src/es/format/uri.clj: -------------------------------------------------------------------------------- 1 | (ns es.format.uri 2 | (:require [clj-http.util :refer [url-encode]])) 3 | 4 | (defn encode 5 | ([s] 6 | (url-encode s))) 7 | 8 | (defn query-string [params] 9 | (if (seq params) 10 | (->> params 11 | (map str) 12 | (interpose "&") 13 | (apply str)) 14 | "")) 15 | 16 | (defn query-flags [flags] 17 | (if (seq flags) 18 | (->> flags 19 | (map name) 20 | (map #(str % "=1")) 21 | query-string))) 22 | -------------------------------------------------------------------------------- /src/es/help.clj: -------------------------------------------------------------------------------- 1 | (ns es.help 2 | (:require [clojure.tools.cli :refer [cli]] 3 | [es.command :as comm] 4 | [es.command.version :as version])) 5 | 6 | (defn help-commands [] 7 | (println "Available commands:") 8 | (println) 9 | (print " ") 10 | (println (->> comm/available 11 | (interpose "\n " ) 12 | (apply str)))) 13 | 14 | (defn help [specs] 15 | (println) 16 | (println "es2unix" (version/version*)) 17 | (println "Copyright 2013 Elasticsearch") 18 | (println) 19 | (println "Opts:") 20 | (println) 21 | (doseq [spec (sort-by second specs)] 22 | (let [[short switch desc & {:keys [default]}] spec] 23 | (println (format "%s %-15s %s (default: %s)" 24 | short switch desc default)))) 25 | (println) 26 | (help-commands)) 27 | -------------------------------------------------------------------------------- /src/es/http.clj: -------------------------------------------------------------------------------- 1 | (ns es.http 2 | (:refer-clojure :exclude [get]) 3 | (:require [clj-http.client :as http] 4 | [cheshire.core :as json] 5 | [es.local :as local] 6 | [slingshot.slingshot :refer [throw+]]) 7 | (:import (java.net URI URL))) 8 | 9 | (defn local? [url] 10 | (and (string? url) (.startsWith url "local:"))) 11 | 12 | (defn get* [url] 13 | (let [uri (URI. url) 14 | [path query] [(.getPath uri) (.getQuery uri)] 15 | getfn (if (= "local" (.getScheme uri)) 16 | #(local/get (str path 17 | (if query 18 | (str "?" query)))) 19 | #(http/get url))] 20 | (try 21 | (-> (getfn) :body (#(json/decode % true))) 22 | (catch java.lang.IllegalArgumentException e 23 | (throw+ {:type ::error 24 | :msg (format "bad url: %s" (.getMessage e))})) 25 | (catch org.apache.http.NoHttpResponseException e 26 | (throw+ {:type ::error 27 | :msg (format "no response from %s" url)})) 28 | (catch java.net.UnknownHostException e 29 | (throw+ {:type ::error 30 | :msg (format "unknown host %s" (.getHost uri))})) 31 | (catch java.net.ConnectException e 32 | (throw+ {:type ::error 33 | :msg (format "can't connect to %s" url)})) 34 | (catch clojure.lang.ExceptionInfo e 35 | (throw+ {:type ::error 36 | :msg (format 37 | "%s: %s" 38 | url (-> e .getData :object :status))})) 39 | (catch java.net.MalformedURLException e 40 | (throw+ {:type ::error 41 | :msg (format 42 | "need complete url (with scheme!): %s" 43 | url)}))))) 44 | 45 | (defn memoize-cond 46 | "Only return memoized value if (pred args) is true." 47 | [f pred] 48 | (let [mem (atom {})] 49 | (fn [& args] 50 | (if (pred args) 51 | (if-let [e (find @mem args)] 52 | (val e) 53 | (let [ret (apply f args)] 54 | (swap! mem assoc args ret) 55 | ret)) 56 | (apply f args))))) 57 | 58 | (def get 59 | (memoize-cond 60 | get* 61 | (fn [args] 62 | (let [[arg] args] 63 | (if (not (local? arg)) true))))) 64 | 65 | (defn fetcher [base] 66 | (fn f 67 | ([] 68 | (f "/")) 69 | ([path] 70 | (let [path (clojure.string/replace path #"^\/+" "") 71 | url (-> (URL. base) (URL. path) str)] 72 | (get url))))) 73 | -------------------------------------------------------------------------------- /src/es/local.clj: -------------------------------------------------------------------------------- 1 | (ns es.local 2 | (:refer-clojure :exclude [get]) 3 | (:require [clojure.java.io :as io])) 4 | 5 | (defn localize-path [path] 6 | (str "output" path ".json")) 7 | 8 | (defn get [uri] 9 | (if-let [f (-> uri 10 | localize-path 11 | io/resource)] 12 | {:status 200 13 | :headers {"content-type" "application/json; charset=UTF-8"} 14 | :body (-> f slurp)} 15 | (throw 16 | (clojure.lang.ExceptionInfo. 17 | (format "not found: %s" uri) 18 | {:object 19 | {:status 404}})))) 20 | -------------------------------------------------------------------------------- /src/es/main.clj: -------------------------------------------------------------------------------- 1 | (ns es.main 2 | (:gen-class) 3 | (:require [clojure.tools.cli :refer [cli]] 4 | [bultitude.core :refer [namespaces-on-classpath]] 5 | [es.format.error :refer [stack-trace]] 6 | [es.format.table :refer [tabler]] 7 | [es.http :as http] 8 | [es.help :refer [help]] 9 | [slingshot.slingshot :refer [try+]])) 10 | 11 | (def opts 12 | [["-u" "--url" "ES instance locator" :default "http://localhost:9200"] 13 | ["-o" "--output" "Output format [only raw right now]" :default :raw] 14 | ["-v" "--verbose" "Print column headings" :flag true :default false] 15 | ["-h" "--help" "Print help" :flag true :default false]]) 16 | 17 | (defn find-command [ns var] 18 | (let [var (symbol (format "%s/%s" ns var))] 19 | (try 20 | (find-var var) 21 | (catch Exception _)))) 22 | 23 | (defn error [fmt & args] 24 | (binding [*out* *err*] 25 | (apply printf (str (.trim fmt) "\n") args) 26 | (flush))) 27 | 28 | (defn die [fmt & args] 29 | (apply error fmt args) 30 | (flush) 31 | (System/exit 1)) 32 | 33 | (defn main [cmd args opts] 34 | (let [cmd (find-command 35 | (symbol (format "es.command.%s" cmd)) 36 | (symbol cmd)) 37 | http (http/fetcher (:url opts))] 38 | (if cmd 39 | (cmd http args opts) 40 | :fail))) 41 | 42 | (defn -main [& args] 43 | (try 44 | (let [[opts* args _] (apply cli args opts)] 45 | (try+ 46 | (let [[cmd & args] args 47 | _ (when (or (:help opts*) 48 | (= cmd "help") 49 | (not cmd)) 50 | (help opts) 51 | (System/exit 0)) 52 | res (main cmd args opts*)] 53 | (condp = res 54 | :fail (if cmd 55 | (die "no command %s" cmd)) 56 | (tabler opts* res))) 57 | (catch [:type :es.http/error] {:keys [msg]} 58 | (die "http error: %s" msg)) 59 | (catch Object _ 60 | (die "unexpected: %s\n%s" &throw-context 61 | (-> &throw-context :throwable stack-trace))))) 62 | (catch Exception e 63 | (help opts)))) 64 | -------------------------------------------------------------------------------- /src/es/util.clj: -------------------------------------------------------------------------------- 1 | (ns es.util) 2 | 3 | (defn maybe-get-in 4 | ([m & ks] 5 | (or (get-in m ks) " "))) 6 | 7 | (defn match-any? 8 | "If any of the string frags match string thing or there are no frags, 9 | return the thing. Otherwise nil." 10 | ([thing frags] 11 | (if (seq frags) 12 | (if (some #(.contains thing %) frags) 13 | thing) 14 | thing))) 15 | 16 | (defn comma-list [idxs] 17 | (if (seq idxs) 18 | (->> idxs 19 | (map #(str "*" % "*")) 20 | (interpose ",") 21 | (apply str)) 22 | "")) 23 | 24 | (defn commafy [n] 25 | (->> (str n) 26 | reverse 27 | (partition-all 3) 28 | (interpose ",") 29 | (apply concat) 30 | reverse 31 | (apply str))) 32 | 33 | (defn substr [s n] 34 | (apply str (take n (str s)))) 35 | 36 | (defn deep-merge-with 37 | "Like merge-with, but merges maps recursively, applying the given fn 38 | only when there's a non-map at a particular level. 39 | 40 | (deep-merge-with + {:a {:b {:c 1 :d {:x 1 :y 2}} :e 3} :f 4} 41 | {:a {:b {:c 2 :d {:z 9} :z 3} :e 100}}) 42 | -> {:a {:b {:z 3, :c 3, :d {:z 9, :x 1, :y 2}}, :e 103}, :f 4}" 43 | [f & maps] 44 | (apply 45 | (fn m [& maps] 46 | (if (every? map? maps) 47 | (apply merge-with m maps) 48 | (apply f maps))) 49 | maps)) 50 | 51 | (defn merge-transpose 52 | " (foo {:a {:k {:d 1}}} 53 | {:b {:k {:d 2}}} 54 | {:c {:k {:d 3} 55 | :j {:d 4}}}) 56 | 57 | => {:k {:a {:d 1} 58 | :b {:d 2} 59 | :c {:d 3}} 60 | :j {:c {:d 4}}} 61 | " 62 | ([& a] 63 | (->> (for [m a 64 | [k1 v1] m 65 | [k2 v2] v1] 66 | [k2 {k1 v2}]) 67 | (map (partial apply hash-map)) 68 | (apply merge-with merge)))) 69 | -------------------------------------------------------------------------------- /src/es/util/math.clj: -------------------------------------------------------------------------------- 1 | (ns es.util.math) 2 | 3 | (defn ratio [a b] 4 | (if (pos? b) 5 | (float (/ a b)) 6 | 0)) 7 | 8 | (defn percent [a b & [precision]] 9 | (let [fmt (format "%%.%sf%%%%" (or precision 1))] 10 | (format fmt (* 100 (ratio a b))))) 11 | -------------------------------------------------------------------------------- /src/es/util/time.clj: -------------------------------------------------------------------------------- 1 | (ns es.util.time 2 | (:import (java.text SimpleDateFormat))) 3 | 4 | (defn now [] 5 | (java.util.Date.)) 6 | 7 | (defn hms 8 | ([] 9 | (hms (now))) 10 | ([date] 11 | (.format (SimpleDateFormat. "HH:mm:ss") date))) 12 | -------------------------------------------------------------------------------- /test/output/_cluster/health.json: -------------------------------------------------------------------------------- 1 | { 2 | "number_of_data_nodes" : 3, 3 | "relocating_shards" : 0, 4 | "status" : "green", 5 | "active_shards" : 3, 6 | "cluster_name" : "elasticsearch", 7 | "active_primary_shards" : 3, 8 | "timed_out" : false, 9 | "initializing_shards" : 0, 10 | "number_of_nodes" : 3, 11 | "unassigned_shards" : 0 12 | } 13 | -------------------------------------------------------------------------------- /test/output/_cluster/nodes.json: -------------------------------------------------------------------------------- 1 | { 2 | "ok" : true, 3 | "nodes" : { 4 | "Uv1Iy8FvR0y6_RzPXKBolg" : { 5 | "hostname" : "beta", 6 | "name" : "Cannonball I", 7 | "transport_address" : "inet[/127.0.0.1:9300]", 8 | "http_address" : "inet[localhost/127.0.0.1:9201]", 9 | "version" : "0.21.0.Beta1-SNAPSHOT" 10 | }, 11 | "j27iagsmQQaeIpl6yU6mCg" : { 12 | "hostname" : "beta", 13 | "name" : "Georgianna Castleberry", 14 | "attributes" : { 15 | "data" : "false", 16 | "client" : "true" 17 | }, 18 | "transport_address" : "inet[/127.0.0.1:9303]", 19 | "http_address" : "inet[localhost/127.0.0.1:9203]", 20 | "version" : "0.21.0.Beta1-SNAPSHOT" 21 | }, 22 | "Q4qgMlrETs67mUL-iGHC4A" : { 23 | "hostname" : "beta", 24 | "name" : "Luichow, Chan", 25 | "transport_address" : "inet[/127.0.0.1:9302]", 26 | "http_address" : "inet[localhost/127.0.0.1:9202]", 27 | "version" : "0.21.0.Beta1-SNAPSHOT" 28 | }, 29 | "AvYWeugwQjqs0cB1vr3D-w" : { 30 | "hostname" : "beta", 31 | "name" : "Eric the Red", 32 | "attributes" : { 33 | "master" : "false" 34 | }, 35 | "transport_address" : "inet[/127.0.0.1:9304]", 36 | "http_address" : "inet[localhost/127.0.0.1:9204]", 37 | "version" : "0.21.0.Beta1-SNAPSHOT" 38 | }, 39 | "J-erllamTOiW5WoGVUd04A" : { 40 | "hostname" : "beta", 41 | "name" : "Slade, Frederick", 42 | "transport_address" : "inet[localhost/127.0.0.1:9301]", 43 | "http_address" : "inet[localhost/127.0.0.1:9200]", 44 | "version" : "0.21.0.Beta1-SNAPSHOT" 45 | } 46 | }, 47 | "cluster_name" : "kluster" 48 | } 49 | -------------------------------------------------------------------------------- /test/output/_cluster/state?filter_metadata=1&filter_routing_table=1&filter_indices=1.json: -------------------------------------------------------------------------------- 1 | { 2 | "nodes" : { 3 | "BbGA6DgrQ4ypROuLuxjSBA" : { 4 | "name" : "Klaw", 5 | "attributes" : {}, 6 | "transport_address" : "inet[/192.168.20.115:9300]" 7 | }, 8 | "zPRCnao_R_CFMo4m00F6iQ" : { 9 | "name" : "Living Pharaoh", 10 | "attributes" : {}, 11 | "transport_address" : "inet[/192.168.20.115:9302]" 12 | }, 13 | "RJpJKcAzSrO1kNoHlDvZBg" : { 14 | "name" : "Missing Link", 15 | "attributes" : {}, 16 | "transport_address" : "inet[/192.168.20.115:9301]" 17 | } 18 | }, 19 | "master_node" : "BbGA6DgrQ4ypROuLuxjSBA", 20 | "cluster_name" : "elasticsearch", 21 | "blocks" : {} 22 | } 23 | -------------------------------------------------------------------------------- /test/output/_nodes.json: -------------------------------------------------------------------------------- 1 | { 2 | "ok" : true, 3 | "nodes" : { 4 | "Q4qgMlrETs67mUL-iGHC4A" : { 5 | "http_address" : "inet[localhost/127.0.0.1:9202]", 6 | "name" : "Luichow, Chan", 7 | "hostname" : "beta", 8 | "version" : "0.21.0.Beta1-SNAPSHOT", 9 | "transport_address" : "inet[/127.0.0.1:9302]" 10 | }, 11 | "J-erllamTOiW5WoGVUd04A" : { 12 | "http_address" : "inet[localhost/127.0.0.1:9200]", 13 | "name" : "Slade, Frederick", 14 | "hostname" : "beta", 15 | "version" : "0.21.0.Beta1-SNAPSHOT", 16 | "transport_address" : "inet[localhost/127.0.0.1:9301]" 17 | }, 18 | "Uv1Iy8FvR0y6_RzPXKBolg" : { 19 | "http_address" : "inet[localhost/127.0.0.1:9201]", 20 | "name" : "Cannonball I", 21 | "hostname" : "beta", 22 | "version" : "0.21.0.Beta1-SNAPSHOT", 23 | "transport_address" : "inet[/127.0.0.1:9300]" 24 | } 25 | }, 26 | "cluster_name" : "kluster" 27 | } 28 | -------------------------------------------------------------------------------- /test/output/_status.json: -------------------------------------------------------------------------------- 1 | { 2 | "indices" : { 3 | "wiki" : { 4 | "merges" : { 5 | "total_size" : "0b", 6 | "total_docs" : 0, 7 | "total_time" : "0s", 8 | "total_time_in_millis" : 0, 9 | "current_size_in_bytes" : 0, 10 | "total" : 0, 11 | "current_docs" : 0, 12 | "current_size" : "0b", 13 | "total_size_in_bytes" : 0, 14 | "current" : 0 15 | }, 16 | "flush" : { 17 | "total_time" : "935ms", 18 | "total_time_in_millis" : 935, 19 | "total" : 250 20 | }, 21 | "docs" : { 22 | "deleted_docs" : 0, 23 | "num_docs" : 143700, 24 | "max_doc" : 143700 25 | }, 26 | "translog" : { 27 | "operations" : 0 28 | }, 29 | "shards" : { 30 | "3" : [ 31 | { 32 | "merges" : { 33 | "total_size" : "0b", 34 | "total_docs" : 0, 35 | "total_time" : "0s", 36 | "total_time_in_millis" : 0, 37 | "current_size_in_bytes" : 0, 38 | "total" : 0, 39 | "current_docs" : 0, 40 | "current_size" : "0b", 41 | "total_size_in_bytes" : 0, 42 | "current" : 0 43 | }, 44 | "flush" : { 45 | "total_time" : "50ms", 46 | "total_time_in_millis" : 50, 47 | "total" : 20 48 | }, 49 | "docs" : { 50 | "deleted_docs" : 0, 51 | "num_docs" : 28761, 52 | "max_doc" : 28761 53 | }, 54 | "state" : "STARTED", 55 | "index" : { 56 | "size" : "409.1mb", 57 | "size_in_bytes" : 429017254 58 | }, 59 | "routing" : { 60 | "primary" : false, 61 | "shard" : 3, 62 | "relocating_node" : null, 63 | "node" : "J-erllamTOiW5WoGVUd04A", 64 | "state" : "STARTED", 65 | "index" : "wiki" 66 | }, 67 | "translog" : { 68 | "id" : 1357760561670, 69 | "operations" : 0 70 | }, 71 | "refresh" : { 72 | "total_time" : "0s", 73 | "total_time_in_millis" : 0, 74 | "total" : 0 75 | } 76 | }, 77 | { 78 | "merges" : { 79 | "total_size" : "0b", 80 | "total_docs" : 0, 81 | "total_time" : "0s", 82 | "total_time_in_millis" : 0, 83 | "current_size_in_bytes" : 0, 84 | "total" : 0, 85 | "current_docs" : 0, 86 | "current_size" : "0b", 87 | "total_size_in_bytes" : 0, 88 | "current" : 0 89 | }, 90 | "flush" : { 91 | "total_time" : "75ms", 92 | "total_time_in_millis" : 75, 93 | "total" : 20 94 | }, 95 | "docs" : { 96 | "deleted_docs" : 0, 97 | "num_docs" : 28761, 98 | "max_doc" : 28761 99 | }, 100 | "state" : "STARTED", 101 | "index" : { 102 | "size" : "409.1mb", 103 | "size_in_bytes" : 429019084 104 | }, 105 | "routing" : { 106 | "primary" : false, 107 | "shard" : 3, 108 | "relocating_node" : null, 109 | "node" : "Q4qgMlrETs67mUL-iGHC4A", 110 | "state" : "STARTED", 111 | "index" : "wiki" 112 | }, 113 | "translog" : { 114 | "id" : 1357760561670, 115 | "operations" : 0 116 | }, 117 | "refresh" : { 118 | "total_time" : "0s", 119 | "total_time_in_millis" : 0, 120 | "total" : 0 121 | } 122 | }, 123 | { 124 | "merges" : { 125 | "total_size" : "0b", 126 | "total_docs" : 0, 127 | "total_time" : "0s", 128 | "total_time_in_millis" : 0, 129 | "current_size_in_bytes" : 0, 130 | "total" : 0, 131 | "current_docs" : 0, 132 | "current_size" : "0b", 133 | "total_size_in_bytes" : 0, 134 | "current" : 0 135 | }, 136 | "flush" : { 137 | "total_time" : "62ms", 138 | "total_time_in_millis" : 62, 139 | "total" : 20 140 | }, 141 | "docs" : { 142 | "deleted_docs" : 0, 143 | "num_docs" : 28761, 144 | "max_doc" : 28761 145 | }, 146 | "state" : "STARTED", 147 | "index" : { 148 | "size" : "409.1mb", 149 | "size_in_bytes" : 429013649 150 | }, 151 | "routing" : { 152 | "primary" : true, 153 | "shard" : 3, 154 | "relocating_node" : null, 155 | "node" : "Uv1Iy8FvR0y6_RzPXKBolg", 156 | "state" : "STARTED", 157 | "index" : "wiki" 158 | }, 159 | "translog" : { 160 | "id" : 1357760561670, 161 | "operations" : 0 162 | }, 163 | "refresh" : { 164 | "total_time" : "0s", 165 | "total_time_in_millis" : 0, 166 | "total" : 1 167 | } 168 | } 169 | ], 170 | "2" : [ 171 | { 172 | "merges" : { 173 | "total_size" : "0b", 174 | "total_docs" : 0, 175 | "total_time" : "0s", 176 | "total_time_in_millis" : 0, 177 | "current_size_in_bytes" : 0, 178 | "total" : 0, 179 | "current_docs" : 0, 180 | "current_size" : "0b", 181 | "total_size_in_bytes" : 0, 182 | "current" : 0 183 | }, 184 | "flush" : { 185 | "total_time" : "53ms", 186 | "total_time_in_millis" : 53, 187 | "total" : 20 188 | }, 189 | "docs" : { 190 | "deleted_docs" : 0, 191 | "num_docs" : 28718, 192 | "max_doc" : 28718 193 | }, 194 | "state" : "STARTED", 195 | "index" : { 196 | "size" : "406.9mb", 197 | "size_in_bytes" : 426738791 198 | }, 199 | "routing" : { 200 | "primary" : false, 201 | "shard" : 2, 202 | "relocating_node" : null, 203 | "node" : "J-erllamTOiW5WoGVUd04A", 204 | "state" : "STARTED", 205 | "index" : "wiki" 206 | }, 207 | "translog" : { 208 | "id" : 1357760561494, 209 | "operations" : 0 210 | }, 211 | "refresh" : { 212 | "total_time" : "0s", 213 | "total_time_in_millis" : 0, 214 | "total" : 0 215 | } 216 | }, 217 | { 218 | "merges" : { 219 | "total_size" : "0b", 220 | "total_docs" : 0, 221 | "total_time" : "0s", 222 | "total_time_in_millis" : 0, 223 | "current_size_in_bytes" : 0, 224 | "total" : 0, 225 | "current_docs" : 0, 226 | "current_size" : "0b", 227 | "total_size_in_bytes" : 0, 228 | "current" : 0 229 | }, 230 | "flush" : { 231 | "total_time" : "101ms", 232 | "total_time_in_millis" : 101, 233 | "total" : 20 234 | }, 235 | "docs" : { 236 | "deleted_docs" : 0, 237 | "num_docs" : 28718, 238 | "max_doc" : 28718 239 | }, 240 | "state" : "STARTED", 241 | "index" : { 242 | "size" : "406.9mb", 243 | "size_in_bytes" : 426734771 244 | }, 245 | "routing" : { 246 | "primary" : true, 247 | "shard" : 2, 248 | "relocating_node" : null, 249 | "node" : "Uv1Iy8FvR0y6_RzPXKBolg", 250 | "state" : "STARTED", 251 | "index" : "wiki" 252 | }, 253 | "translog" : { 254 | "id" : 1357760561494, 255 | "operations" : 0 256 | }, 257 | "refresh" : { 258 | "total_time" : "0s", 259 | "total_time_in_millis" : 0, 260 | "total" : 1 261 | } 262 | }, 263 | { 264 | "merges" : { 265 | "total_size" : "0b", 266 | "total_docs" : 0, 267 | "total_time" : "0s", 268 | "total_time_in_millis" : 0, 269 | "current_size_in_bytes" : 0, 270 | "total" : 0, 271 | "current_docs" : 0, 272 | "current_size" : "0b", 273 | "total_size_in_bytes" : 0, 274 | "current" : 0 275 | }, 276 | "flush" : { 277 | "total_time" : "12ms", 278 | "total_time_in_millis" : 12, 279 | "total" : 4 280 | }, 281 | "docs" : { 282 | "deleted_docs" : 0, 283 | "num_docs" : 28718, 284 | "max_doc" : 28718 285 | }, 286 | "state" : "STARTED", 287 | "index" : { 288 | "size" : "406.9mb", 289 | "size_in_bytes" : 426734751 290 | }, 291 | "routing" : { 292 | "primary" : false, 293 | "shard" : 2, 294 | "relocating_node" : null, 295 | "node" : "AvYWeugwQjqs0cB1vr3D-w", 296 | "state" : "STARTED", 297 | "index" : "wiki" 298 | }, 299 | "translog" : { 300 | "id" : 1357760561494, 301 | "operations" : 0 302 | }, 303 | "refresh" : { 304 | "total_time" : "0s", 305 | "total_time_in_millis" : 0, 306 | "total" : 0 307 | } 308 | } 309 | ], 310 | "0" : [ 311 | { 312 | "merges" : { 313 | "total_size" : "0b", 314 | "total_docs" : 0, 315 | "total_time" : "0s", 316 | "total_time_in_millis" : 0, 317 | "current_size_in_bytes" : 0, 318 | "total" : 0, 319 | "current_docs" : 0, 320 | "current_size" : "0b", 321 | "total_size_in_bytes" : 0, 322 | "current" : 0 323 | }, 324 | "flush" : { 325 | "total_time" : "72ms", 326 | "total_time_in_millis" : 72, 327 | "total" : 20 328 | }, 329 | "docs" : { 330 | "deleted_docs" : 0, 331 | "num_docs" : 28826, 332 | "max_doc" : 28826 333 | }, 334 | "state" : "STARTED", 335 | "index" : { 336 | "size" : "404.8mb", 337 | "size_in_bytes" : 424547838 338 | }, 339 | "routing" : { 340 | "primary" : false, 341 | "shard" : 0, 342 | "relocating_node" : null, 343 | "node" : "Q4qgMlrETs67mUL-iGHC4A", 344 | "state" : "STARTED", 345 | "index" : "wiki" 346 | }, 347 | "translog" : { 348 | "id" : 1357760561279, 349 | "operations" : 0 350 | }, 351 | "refresh" : { 352 | "total_time" : "0s", 353 | "total_time_in_millis" : 0, 354 | "total" : 0 355 | } 356 | }, 357 | { 358 | "merges" : { 359 | "total_size" : "0b", 360 | "total_docs" : 0, 361 | "total_time" : "0s", 362 | "total_time_in_millis" : 0, 363 | "current_size_in_bytes" : 0, 364 | "total" : 0, 365 | "current_docs" : 0, 366 | "current_size" : "0b", 367 | "total_size_in_bytes" : 0, 368 | "current" : 0 369 | }, 370 | "flush" : { 371 | "total_time" : "146ms", 372 | "total_time_in_millis" : 146, 373 | "total" : 20 374 | }, 375 | "docs" : { 376 | "deleted_docs" : 0, 377 | "num_docs" : 28826, 378 | "max_doc" : 28826 379 | }, 380 | "state" : "STARTED", 381 | "index" : { 382 | "size" : "404.8mb", 383 | "size_in_bytes" : 424543981 384 | }, 385 | "routing" : { 386 | "primary" : true, 387 | "shard" : 0, 388 | "relocating_node" : null, 389 | "node" : "Uv1Iy8FvR0y6_RzPXKBolg", 390 | "state" : "STARTED", 391 | "index" : "wiki" 392 | }, 393 | "translog" : { 394 | "id" : 1357760561279, 395 | "operations" : 0 396 | }, 397 | "refresh" : { 398 | "total_time" : "0s", 399 | "total_time_in_millis" : 0, 400 | "total" : 1 401 | } 402 | }, 403 | { 404 | "merges" : { 405 | "total_size" : "0b", 406 | "total_docs" : 0, 407 | "total_time" : "0s", 408 | "total_time_in_millis" : 0, 409 | "current_size_in_bytes" : 0, 410 | "total" : 0, 411 | "current_docs" : 0, 412 | "current_size" : "0b", 413 | "total_size_in_bytes" : 0, 414 | "current" : 0 415 | }, 416 | "flush" : { 417 | "total_time" : "14ms", 418 | "total_time_in_millis" : 14, 419 | "total" : 4 420 | }, 421 | "docs" : { 422 | "deleted_docs" : 0, 423 | "num_docs" : 28826, 424 | "max_doc" : 28826 425 | }, 426 | "state" : "STARTED", 427 | "index" : { 428 | "size" : "404.8mb", 429 | "size_in_bytes" : 424543961 430 | }, 431 | "routing" : { 432 | "primary" : false, 433 | "shard" : 0, 434 | "relocating_node" : null, 435 | "node" : "AvYWeugwQjqs0cB1vr3D-w", 436 | "state" : "STARTED", 437 | "index" : "wiki" 438 | }, 439 | "translog" : { 440 | "id" : 1357760561279, 441 | "operations" : 0 442 | }, 443 | "refresh" : { 444 | "total_time" : "0s", 445 | "total_time_in_millis" : 0, 446 | "total" : 0 447 | } 448 | } 449 | ], 450 | "4" : [ 451 | { 452 | "merges" : { 453 | "total_size" : "0b", 454 | "total_docs" : 0, 455 | "total_time" : "0s", 456 | "total_time_in_millis" : 0, 457 | "current_size_in_bytes" : 0, 458 | "total" : 0, 459 | "current_docs" : 0, 460 | "current_size" : "0b", 461 | "total_size_in_bytes" : 0, 462 | "current" : 0 463 | }, 464 | "flush" : { 465 | "total_time" : "58ms", 466 | "total_time_in_millis" : 58, 467 | "total" : 19 468 | }, 469 | "docs" : { 470 | "deleted_docs" : 0, 471 | "num_docs" : 28819, 472 | "max_doc" : 28819 473 | }, 474 | "state" : "STARTED", 475 | "index" : { 476 | "size" : "410.6mb", 477 | "size_in_bytes" : 430611290 478 | }, 479 | "routing" : { 480 | "primary" : false, 481 | "shard" : 4, 482 | "relocating_node" : null, 483 | "node" : "J-erllamTOiW5WoGVUd04A", 484 | "state" : "STARTED", 485 | "index" : "wiki" 486 | }, 487 | "translog" : { 488 | "id" : 1357760561586, 489 | "operations" : 0 490 | }, 491 | "refresh" : { 492 | "total_time" : "0s", 493 | "total_time_in_millis" : 0, 494 | "total" : 0 495 | } 496 | }, 497 | { 498 | "merges" : { 499 | "total_size" : "0b", 500 | "total_docs" : 0, 501 | "total_time" : "0s", 502 | "total_time_in_millis" : 0, 503 | "current_size_in_bytes" : 0, 504 | "total" : 0, 505 | "current_docs" : 0, 506 | "current_size" : "0b", 507 | "total_size_in_bytes" : 0, 508 | "current" : 0 509 | }, 510 | "flush" : { 511 | "total_time" : "63ms", 512 | "total_time_in_millis" : 63, 513 | "total" : 19 514 | }, 515 | "docs" : { 516 | "deleted_docs" : 0, 517 | "num_docs" : 28819, 518 | "max_doc" : 28819 519 | }, 520 | "state" : "STARTED", 521 | "index" : { 522 | "size" : "410.6mb", 523 | "size_in_bytes" : 430612693 524 | }, 525 | "routing" : { 526 | "primary" : false, 527 | "shard" : 4, 528 | "relocating_node" : null, 529 | "node" : "Q4qgMlrETs67mUL-iGHC4A", 530 | "state" : "STARTED", 531 | "index" : "wiki" 532 | }, 533 | "translog" : { 534 | "id" : 1357760561586, 535 | "operations" : 0 536 | }, 537 | "refresh" : { 538 | "total_time" : "0s", 539 | "total_time_in_millis" : 0, 540 | "total" : 0 541 | } 542 | }, 543 | { 544 | "merges" : { 545 | "total_size" : "0b", 546 | "total_docs" : 0, 547 | "total_time" : "0s", 548 | "total_time_in_millis" : 0, 549 | "current_size_in_bytes" : 0, 550 | "total" : 0, 551 | "current_docs" : 0, 552 | "current_size" : "0b", 553 | "total_size_in_bytes" : 0, 554 | "current" : 0 555 | }, 556 | "flush" : { 557 | "total_time" : "109ms", 558 | "total_time_in_millis" : 109, 559 | "total" : 20 560 | }, 561 | "docs" : { 562 | "deleted_docs" : 0, 563 | "num_docs" : 28819, 564 | "max_doc" : 28819 565 | }, 566 | "state" : "STARTED", 567 | "index" : { 568 | "size" : "410.6mb", 569 | "size_in_bytes" : 430608757 570 | }, 571 | "routing" : { 572 | "primary" : true, 573 | "shard" : 4, 574 | "relocating_node" : null, 575 | "node" : "Uv1Iy8FvR0y6_RzPXKBolg", 576 | "state" : "STARTED", 577 | "index" : "wiki" 578 | }, 579 | "translog" : { 580 | "id" : 1357760561586, 581 | "operations" : 0 582 | }, 583 | "refresh" : { 584 | "total_time" : "0s", 585 | "total_time_in_millis" : 0, 586 | "total" : 1 587 | } 588 | } 589 | ], 590 | "1" : [ 591 | { 592 | "merges" : { 593 | "total_size" : "0b", 594 | "total_docs" : 0, 595 | "total_time" : "0s", 596 | "total_time_in_millis" : 0, 597 | "current_size_in_bytes" : 0, 598 | "total" : 0, 599 | "current_docs" : 0, 600 | "current_size" : "0b", 601 | "total_size_in_bytes" : 0, 602 | "current" : 0 603 | }, 604 | "flush" : { 605 | "total_time" : "51ms", 606 | "total_time_in_millis" : 51, 607 | "total" : 20 608 | }, 609 | "docs" : { 610 | "deleted_docs" : 0, 611 | "num_docs" : 28576, 612 | "max_doc" : 28576 613 | }, 614 | "state" : "STARTED", 615 | "index" : { 616 | "size" : "404.2mb", 617 | "size_in_bytes" : 423851451 618 | }, 619 | "routing" : { 620 | "primary" : true, 621 | "shard" : 1, 622 | "relocating_node" : null, 623 | "node" : "J-erllamTOiW5WoGVUd04A", 624 | "state" : "STARTED", 625 | "index" : "wiki" 626 | }, 627 | "translog" : { 628 | "id" : 1357760561393, 629 | "operations" : 0 630 | }, 631 | "refresh" : { 632 | "total_time" : "0s", 633 | "total_time_in_millis" : 0, 634 | "total" : 0 635 | } 636 | }, 637 | { 638 | "merges" : { 639 | "total_size" : "0b", 640 | "total_docs" : 0, 641 | "total_time" : "0s", 642 | "total_time_in_millis" : 0, 643 | "current_size_in_bytes" : 0, 644 | "total" : 0, 645 | "current_docs" : 0, 646 | "current_size" : "0b", 647 | "total_size_in_bytes" : 0, 648 | "current" : 0 649 | }, 650 | "flush" : { 651 | "total_time" : "55ms", 652 | "total_time_in_millis" : 55, 653 | "total" : 20 654 | }, 655 | "docs" : { 656 | "deleted_docs" : 0, 657 | "num_docs" : 28576, 658 | "max_doc" : 28576 659 | }, 660 | "state" : "STARTED", 661 | "index" : { 662 | "size" : "404.2mb", 663 | "size_in_bytes" : 423848976 664 | }, 665 | "routing" : { 666 | "primary" : false, 667 | "shard" : 1, 668 | "relocating_node" : null, 669 | "node" : "Q4qgMlrETs67mUL-iGHC4A", 670 | "state" : "STARTED", 671 | "index" : "wiki" 672 | }, 673 | "translog" : { 674 | "id" : 1357760561393, 675 | "operations" : 0 676 | }, 677 | "refresh" : { 678 | "total_time" : "0s", 679 | "total_time_in_millis" : 0, 680 | "total" : 0 681 | } 682 | }, 683 | { 684 | "merges" : { 685 | "total_size" : "0b", 686 | "total_docs" : 0, 687 | "total_time" : "0s", 688 | "total_time_in_millis" : 0, 689 | "current_size_in_bytes" : 0, 690 | "total" : 0, 691 | "current_docs" : 0, 692 | "current_size" : "0b", 693 | "total_size_in_bytes" : 0, 694 | "current" : 0 695 | }, 696 | "flush" : { 697 | "total_time" : "14ms", 698 | "total_time_in_millis" : 14, 699 | "total" : 4 700 | }, 701 | "docs" : { 702 | "deleted_docs" : 0, 703 | "num_docs" : 28576, 704 | "max_doc" : 28576 705 | }, 706 | "state" : "STARTED", 707 | "index" : { 708 | "size" : "404.2mb", 709 | "size_in_bytes" : 423845459 710 | }, 711 | "routing" : { 712 | "primary" : false, 713 | "shard" : 1, 714 | "relocating_node" : null, 715 | "node" : "AvYWeugwQjqs0cB1vr3D-w", 716 | "state" : "STARTED", 717 | "index" : "wiki" 718 | }, 719 | "translog" : { 720 | "id" : 1357760561393, 721 | "operations" : 0 722 | }, 723 | "refresh" : { 724 | "total_time" : "0s", 725 | "total_time_in_millis" : 0, 726 | "total" : 0 727 | } 728 | } 729 | ] 730 | }, 731 | "refresh" : { 732 | "total_time" : "0s", 733 | "total_time_in_millis" : 0, 734 | "total" : 4 735 | }, 736 | "index" : { 737 | "size" : "5.9gb", 738 | "size_in_bytes" : 6404272706, 739 | "primary_size" : "1.9gb", 740 | "primary_size_in_bytes" : 2134752609 741 | } 742 | }, 743 | "_river" : { 744 | "merges" : { 745 | "total_size" : "0b", 746 | "total_docs" : 0, 747 | "total_time" : "0s", 748 | "total_time_in_millis" : 0, 749 | "current_size_in_bytes" : 0, 750 | "total" : 0, 751 | "current_docs" : 0, 752 | "current_size" : "0b", 753 | "total_size_in_bytes" : 0, 754 | "current" : 0 755 | }, 756 | "flush" : { 757 | "total_time" : "2.2s", 758 | "total_time_in_millis" : 2235, 759 | "total" : 25 760 | }, 761 | "docs" : { 762 | "deleted_docs" : 0, 763 | "num_docs" : 0, 764 | "max_doc" : 0 765 | }, 766 | "translog" : { 767 | "operations" : 0 768 | }, 769 | "shards" : { 770 | "0" : [ 771 | { 772 | "merges" : { 773 | "total_size" : "0b", 774 | "total_docs" : 0, 775 | "total_time" : "0s", 776 | "total_time_in_millis" : 0, 777 | "current_size_in_bytes" : 0, 778 | "total" : 0, 779 | "current_docs" : 0, 780 | "current_size" : "0b", 781 | "total_size_in_bytes" : 0, 782 | "current" : 0 783 | }, 784 | "flush" : { 785 | "total_time" : "2.2s", 786 | "total_time_in_millis" : 2234, 787 | "total" : 21 788 | }, 789 | "docs" : { 790 | "deleted_docs" : 0, 791 | "num_docs" : 0, 792 | "max_doc" : 0 793 | }, 794 | "state" : "STARTED", 795 | "index" : { 796 | "size" : "797b", 797 | "size_in_bytes" : 797 798 | }, 799 | "routing" : { 800 | "primary" : true, 801 | "shard" : 0, 802 | "relocating_node" : null, 803 | "node" : "Uv1Iy8FvR0y6_RzPXKBolg", 804 | "state" : "STARTED", 805 | "index" : "_river" 806 | }, 807 | "translog" : { 808 | "id" : 1357760560900, 809 | "operations" : 0 810 | }, 811 | "refresh" : { 812 | "total_time" : "0s", 813 | "total_time_in_millis" : 0, 814 | "total" : 1 815 | } 816 | }, 817 | { 818 | "merges" : { 819 | "total_size" : "0b", 820 | "total_docs" : 0, 821 | "total_time" : "0s", 822 | "total_time_in_millis" : 0, 823 | "current_size_in_bytes" : 0, 824 | "total" : 0, 825 | "current_docs" : 0, 826 | "current_size" : "0b", 827 | "total_size_in_bytes" : 0, 828 | "current" : 0 829 | }, 830 | "flush" : { 831 | "total_time" : "1ms", 832 | "total_time_in_millis" : 1, 833 | "total" : 4 834 | }, 835 | "docs" : { 836 | "deleted_docs" : 0, 837 | "num_docs" : 0, 838 | "max_doc" : 0 839 | }, 840 | "state" : "STARTED", 841 | "index" : { 842 | "size" : "79b", 843 | "size_in_bytes" : 79 844 | }, 845 | "routing" : { 846 | "primary" : false, 847 | "shard" : 0, 848 | "relocating_node" : null, 849 | "node" : "AvYWeugwQjqs0cB1vr3D-w", 850 | "state" : "STARTED", 851 | "index" : "_river" 852 | }, 853 | "translog" : { 854 | "id" : 1357760560900, 855 | "operations" : 0 856 | }, 857 | "refresh" : { 858 | "total_time" : "0s", 859 | "total_time_in_millis" : 0, 860 | "total" : 0 861 | } 862 | } 863 | ] 864 | }, 865 | "refresh" : { 866 | "total_time" : "0s", 867 | "total_time_in_millis" : 0, 868 | "total" : 1 869 | }, 870 | "index" : { 871 | "size" : "876b", 872 | "size_in_bytes" : 876, 873 | "primary_size" : "797b", 874 | "primary_size_in_bytes" : 797 875 | } 876 | } 877 | }, 878 | "ok" : true, 879 | "_shards" : { 880 | "failed" : 0, 881 | "successful" : 17, 882 | "total" : 17 883 | } 884 | } 885 | -------------------------------------------------------------------------------- /test/output/wik*/_status.json: -------------------------------------------------------------------------------- 1 | { 2 | "indices" : { 3 | "wiki" : { 4 | "shards" : { 5 | "3" : [ 6 | { 7 | "merges" : { 8 | "current_size" : "0b", 9 | "current_docs" : 0, 10 | "total_size" : "0b", 11 | "current_size_in_bytes" : 0, 12 | "current" : 0, 13 | "total_time" : "0s", 14 | "total_time_in_millis" : 0, 15 | "total_docs" : 0, 16 | "total" : 0, 17 | "total_size_in_bytes" : 0 18 | }, 19 | "flush" : { 20 | "total_time_in_millis" : 50, 21 | "total_time" : "50ms", 22 | "total" : 20 23 | }, 24 | "refresh" : { 25 | "total_time_in_millis" : 0, 26 | "total_time" : "0s", 27 | "total" : 0 28 | }, 29 | "translog" : { 30 | "operations" : 0, 31 | "id" : 1357760561670 32 | }, 33 | "routing" : { 34 | "shard" : 3, 35 | "state" : "STARTED", 36 | "relocating_node" : null, 37 | "node" : "J-erllamTOiW5WoGVUd04A", 38 | "primary" : false, 39 | "index" : "wiki" 40 | }, 41 | "state" : "STARTED", 42 | "index" : { 43 | "size" : "409.1mb", 44 | "size_in_bytes" : 429017254 45 | }, 46 | "docs" : { 47 | "deleted_docs" : 0, 48 | "max_doc" : 28761, 49 | "num_docs" : 28761 50 | } 51 | }, 52 | { 53 | "merges" : { 54 | "current_size" : "0b", 55 | "current_docs" : 0, 56 | "total_size" : "0b", 57 | "current_size_in_bytes" : 0, 58 | "current" : 0, 59 | "total_time" : "0s", 60 | "total_time_in_millis" : 0, 61 | "total_docs" : 0, 62 | "total" : 0, 63 | "total_size_in_bytes" : 0 64 | }, 65 | "flush" : { 66 | "total_time_in_millis" : 62, 67 | "total_time" : "62ms", 68 | "total" : 20 69 | }, 70 | "refresh" : { 71 | "total_time_in_millis" : 0, 72 | "total_time" : "0s", 73 | "total" : 1 74 | }, 75 | "translog" : { 76 | "operations" : 0, 77 | "id" : 1357760561670 78 | }, 79 | "routing" : { 80 | "shard" : 3, 81 | "state" : "STARTED", 82 | "relocating_node" : null, 83 | "node" : "Uv1Iy8FvR0y6_RzPXKBolg", 84 | "primary" : true, 85 | "index" : "wiki" 86 | }, 87 | "state" : "STARTED", 88 | "index" : { 89 | "size" : "409.1mb", 90 | "size_in_bytes" : 429013649 91 | }, 92 | "docs" : { 93 | "deleted_docs" : 0, 94 | "max_doc" : 28761, 95 | "num_docs" : 28761 96 | } 97 | }, 98 | { 99 | "merges" : { 100 | "current_size" : "0b", 101 | "current_docs" : 0, 102 | "total_size" : "0b", 103 | "current_size_in_bytes" : 0, 104 | "current" : 0, 105 | "total_time" : "0s", 106 | "total_time_in_millis" : 0, 107 | "total_docs" : 0, 108 | "total" : 0, 109 | "total_size_in_bytes" : 0 110 | }, 111 | "flush" : { 112 | "total_time_in_millis" : 75, 113 | "total_time" : "75ms", 114 | "total" : 20 115 | }, 116 | "refresh" : { 117 | "total_time_in_millis" : 0, 118 | "total_time" : "0s", 119 | "total" : 0 120 | }, 121 | "translog" : { 122 | "operations" : 0, 123 | "id" : 1357760561670 124 | }, 125 | "routing" : { 126 | "shard" : 3, 127 | "state" : "STARTED", 128 | "relocating_node" : null, 129 | "node" : "Q4qgMlrETs67mUL-iGHC4A", 130 | "primary" : false, 131 | "index" : "wiki" 132 | }, 133 | "state" : "STARTED", 134 | "index" : { 135 | "size" : "409.1mb", 136 | "size_in_bytes" : 429019084 137 | }, 138 | "docs" : { 139 | "deleted_docs" : 0, 140 | "max_doc" : 28761, 141 | "num_docs" : 28761 142 | } 143 | } 144 | ], 145 | "2" : [ 146 | { 147 | "merges" : { 148 | "current_size" : "0b", 149 | "current_docs" : 0, 150 | "total_size" : "0b", 151 | "current_size_in_bytes" : 0, 152 | "current" : 0, 153 | "total_time" : "0s", 154 | "total_time_in_millis" : 0, 155 | "total_docs" : 0, 156 | "total" : 0, 157 | "total_size_in_bytes" : 0 158 | }, 159 | "flush" : { 160 | "total_time_in_millis" : 53, 161 | "total_time" : "53ms", 162 | "total" : 20 163 | }, 164 | "refresh" : { 165 | "total_time_in_millis" : 0, 166 | "total_time" : "0s", 167 | "total" : 0 168 | }, 169 | "translog" : { 170 | "operations" : 0, 171 | "id" : 1357760561494 172 | }, 173 | "routing" : { 174 | "shard" : 2, 175 | "state" : "STARTED", 176 | "relocating_node" : null, 177 | "node" : "J-erllamTOiW5WoGVUd04A", 178 | "primary" : false, 179 | "index" : "wiki" 180 | }, 181 | "state" : "STARTED", 182 | "index" : { 183 | "size" : "406.9mb", 184 | "size_in_bytes" : 426738791 185 | }, 186 | "docs" : { 187 | "deleted_docs" : 0, 188 | "max_doc" : 28718, 189 | "num_docs" : 28718 190 | } 191 | }, 192 | { 193 | "merges" : { 194 | "current_size" : "0b", 195 | "current_docs" : 0, 196 | "total_size" : "0b", 197 | "current_size_in_bytes" : 0, 198 | "current" : 0, 199 | "total_time" : "0s", 200 | "total_time_in_millis" : 0, 201 | "total_docs" : 0, 202 | "total" : 0, 203 | "total_size_in_bytes" : 0 204 | }, 205 | "flush" : { 206 | "total_time_in_millis" : 101, 207 | "total_time" : "101ms", 208 | "total" : 20 209 | }, 210 | "refresh" : { 211 | "total_time_in_millis" : 0, 212 | "total_time" : "0s", 213 | "total" : 1 214 | }, 215 | "translog" : { 216 | "operations" : 0, 217 | "id" : 1357760561494 218 | }, 219 | "routing" : { 220 | "shard" : 2, 221 | "state" : "STARTED", 222 | "relocating_node" : null, 223 | "node" : "Uv1Iy8FvR0y6_RzPXKBolg", 224 | "primary" : true, 225 | "index" : "wiki" 226 | }, 227 | "state" : "STARTED", 228 | "index" : { 229 | "size" : "406.9mb", 230 | "size_in_bytes" : 426734771 231 | }, 232 | "docs" : { 233 | "deleted_docs" : 0, 234 | "max_doc" : 28718, 235 | "num_docs" : 28718 236 | } 237 | }, 238 | { 239 | "merges" : { 240 | "current_size" : "0b", 241 | "current_docs" : 0, 242 | "total_size" : "0b", 243 | "current_size_in_bytes" : 0, 244 | "current" : 0, 245 | "total_time" : "0s", 246 | "total_time_in_millis" : 0, 247 | "total_docs" : 0, 248 | "total" : 0, 249 | "total_size_in_bytes" : 0 250 | }, 251 | "flush" : { 252 | "total_time_in_millis" : 12, 253 | "total_time" : "12ms", 254 | "total" : 4 255 | }, 256 | "refresh" : { 257 | "total_time_in_millis" : 0, 258 | "total_time" : "0s", 259 | "total" : 0 260 | }, 261 | "translog" : { 262 | "operations" : 0, 263 | "id" : 1357760561494 264 | }, 265 | "routing" : { 266 | "shard" : 2, 267 | "state" : "STARTED", 268 | "relocating_node" : null, 269 | "node" : "AvYWeugwQjqs0cB1vr3D-w", 270 | "primary" : false, 271 | "index" : "wiki" 272 | }, 273 | "state" : "STARTED", 274 | "index" : { 275 | "size" : "406.9mb", 276 | "size_in_bytes" : 426734751 277 | }, 278 | "docs" : { 279 | "deleted_docs" : 0, 280 | "max_doc" : 28718, 281 | "num_docs" : 28718 282 | } 283 | } 284 | ], 285 | "4" : [ 286 | { 287 | "merges" : { 288 | "current_size" : "0b", 289 | "current_docs" : 0, 290 | "total_size" : "0b", 291 | "current_size_in_bytes" : 0, 292 | "current" : 0, 293 | "total_time" : "0s", 294 | "total_time_in_millis" : 0, 295 | "total_docs" : 0, 296 | "total" : 0, 297 | "total_size_in_bytes" : 0 298 | }, 299 | "flush" : { 300 | "total_time_in_millis" : 58, 301 | "total_time" : "58ms", 302 | "total" : 19 303 | }, 304 | "refresh" : { 305 | "total_time_in_millis" : 0, 306 | "total_time" : "0s", 307 | "total" : 0 308 | }, 309 | "translog" : { 310 | "operations" : 0, 311 | "id" : 1357760561586 312 | }, 313 | "routing" : { 314 | "shard" : 4, 315 | "state" : "STARTED", 316 | "relocating_node" : null, 317 | "node" : "J-erllamTOiW5WoGVUd04A", 318 | "primary" : false, 319 | "index" : "wiki" 320 | }, 321 | "state" : "STARTED", 322 | "index" : { 323 | "size" : "410.6mb", 324 | "size_in_bytes" : 430611290 325 | }, 326 | "docs" : { 327 | "deleted_docs" : 0, 328 | "max_doc" : 28819, 329 | "num_docs" : 28819 330 | } 331 | }, 332 | { 333 | "merges" : { 334 | "current_size" : "0b", 335 | "current_docs" : 0, 336 | "total_size" : "0b", 337 | "current_size_in_bytes" : 0, 338 | "current" : 0, 339 | "total_time" : "0s", 340 | "total_time_in_millis" : 0, 341 | "total_docs" : 0, 342 | "total" : 0, 343 | "total_size_in_bytes" : 0 344 | }, 345 | "flush" : { 346 | "total_time_in_millis" : 109, 347 | "total_time" : "109ms", 348 | "total" : 20 349 | }, 350 | "refresh" : { 351 | "total_time_in_millis" : 0, 352 | "total_time" : "0s", 353 | "total" : 1 354 | }, 355 | "translog" : { 356 | "operations" : 0, 357 | "id" : 1357760561586 358 | }, 359 | "routing" : { 360 | "shard" : 4, 361 | "state" : "STARTED", 362 | "relocating_node" : null, 363 | "node" : "Uv1Iy8FvR0y6_RzPXKBolg", 364 | "primary" : true, 365 | "index" : "wiki" 366 | }, 367 | "state" : "STARTED", 368 | "index" : { 369 | "size" : "410.6mb", 370 | "size_in_bytes" : 430608757 371 | }, 372 | "docs" : { 373 | "deleted_docs" : 0, 374 | "max_doc" : 28819, 375 | "num_docs" : 28819 376 | } 377 | }, 378 | { 379 | "merges" : { 380 | "current_size" : "0b", 381 | "current_docs" : 0, 382 | "total_size" : "0b", 383 | "current_size_in_bytes" : 0, 384 | "current" : 0, 385 | "total_time" : "0s", 386 | "total_time_in_millis" : 0, 387 | "total_docs" : 0, 388 | "total" : 0, 389 | "total_size_in_bytes" : 0 390 | }, 391 | "flush" : { 392 | "total_time_in_millis" : 63, 393 | "total_time" : "63ms", 394 | "total" : 19 395 | }, 396 | "refresh" : { 397 | "total_time_in_millis" : 0, 398 | "total_time" : "0s", 399 | "total" : 0 400 | }, 401 | "translog" : { 402 | "operations" : 0, 403 | "id" : 1357760561586 404 | }, 405 | "routing" : { 406 | "shard" : 4, 407 | "state" : "STARTED", 408 | "relocating_node" : null, 409 | "node" : "Q4qgMlrETs67mUL-iGHC4A", 410 | "primary" : false, 411 | "index" : "wiki" 412 | }, 413 | "state" : "STARTED", 414 | "index" : { 415 | "size" : "410.6mb", 416 | "size_in_bytes" : 430612693 417 | }, 418 | "docs" : { 419 | "deleted_docs" : 0, 420 | "max_doc" : 28819, 421 | "num_docs" : 28819 422 | } 423 | } 424 | ], 425 | "0" : [ 426 | { 427 | "merges" : { 428 | "current_size" : "0b", 429 | "current_docs" : 0, 430 | "total_size" : "0b", 431 | "current_size_in_bytes" : 0, 432 | "current" : 0, 433 | "total_time" : "0s", 434 | "total_time_in_millis" : 0, 435 | "total_docs" : 0, 436 | "total" : 0, 437 | "total_size_in_bytes" : 0 438 | }, 439 | "flush" : { 440 | "total_time_in_millis" : 146, 441 | "total_time" : "146ms", 442 | "total" : 20 443 | }, 444 | "refresh" : { 445 | "total_time_in_millis" : 0, 446 | "total_time" : "0s", 447 | "total" : 1 448 | }, 449 | "translog" : { 450 | "operations" : 0, 451 | "id" : 1357760561279 452 | }, 453 | "routing" : { 454 | "shard" : 0, 455 | "state" : "STARTED", 456 | "relocating_node" : null, 457 | "node" : "Uv1Iy8FvR0y6_RzPXKBolg", 458 | "primary" : true, 459 | "index" : "wiki" 460 | }, 461 | "state" : "STARTED", 462 | "index" : { 463 | "size" : "404.8mb", 464 | "size_in_bytes" : 424543981 465 | }, 466 | "docs" : { 467 | "deleted_docs" : 0, 468 | "max_doc" : 28826, 469 | "num_docs" : 28826 470 | } 471 | }, 472 | { 473 | "merges" : { 474 | "current_size" : "0b", 475 | "current_docs" : 0, 476 | "total_size" : "0b", 477 | "current_size_in_bytes" : 0, 478 | "current" : 0, 479 | "total_time" : "0s", 480 | "total_time_in_millis" : 0, 481 | "total_docs" : 0, 482 | "total" : 0, 483 | "total_size_in_bytes" : 0 484 | }, 485 | "flush" : { 486 | "total_time_in_millis" : 72, 487 | "total_time" : "72ms", 488 | "total" : 20 489 | }, 490 | "refresh" : { 491 | "total_time_in_millis" : 0, 492 | "total_time" : "0s", 493 | "total" : 0 494 | }, 495 | "translog" : { 496 | "operations" : 0, 497 | "id" : 1357760561279 498 | }, 499 | "routing" : { 500 | "shard" : 0, 501 | "state" : "STARTED", 502 | "relocating_node" : null, 503 | "node" : "Q4qgMlrETs67mUL-iGHC4A", 504 | "primary" : false, 505 | "index" : "wiki" 506 | }, 507 | "state" : "STARTED", 508 | "index" : { 509 | "size" : "404.8mb", 510 | "size_in_bytes" : 424547838 511 | }, 512 | "docs" : { 513 | "deleted_docs" : 0, 514 | "max_doc" : 28826, 515 | "num_docs" : 28826 516 | } 517 | }, 518 | { 519 | "merges" : { 520 | "current_size" : "0b", 521 | "current_docs" : 0, 522 | "total_size" : "0b", 523 | "current_size_in_bytes" : 0, 524 | "current" : 0, 525 | "total_time" : "0s", 526 | "total_time_in_millis" : 0, 527 | "total_docs" : 0, 528 | "total" : 0, 529 | "total_size_in_bytes" : 0 530 | }, 531 | "flush" : { 532 | "total_time_in_millis" : 14, 533 | "total_time" : "14ms", 534 | "total" : 4 535 | }, 536 | "refresh" : { 537 | "total_time_in_millis" : 0, 538 | "total_time" : "0s", 539 | "total" : 0 540 | }, 541 | "translog" : { 542 | "operations" : 0, 543 | "id" : 1357760561279 544 | }, 545 | "routing" : { 546 | "shard" : 0, 547 | "state" : "STARTED", 548 | "relocating_node" : null, 549 | "node" : "AvYWeugwQjqs0cB1vr3D-w", 550 | "primary" : false, 551 | "index" : "wiki" 552 | }, 553 | "state" : "STARTED", 554 | "index" : { 555 | "size" : "404.8mb", 556 | "size_in_bytes" : 424543961 557 | }, 558 | "docs" : { 559 | "deleted_docs" : 0, 560 | "max_doc" : 28826, 561 | "num_docs" : 28826 562 | } 563 | } 564 | ], 565 | "1" : [ 566 | { 567 | "merges" : { 568 | "current_size" : "0b", 569 | "current_docs" : 0, 570 | "total_size" : "0b", 571 | "current_size_in_bytes" : 0, 572 | "current" : 0, 573 | "total_time" : "0s", 574 | "total_time_in_millis" : 0, 575 | "total_docs" : 0, 576 | "total" : 0, 577 | "total_size_in_bytes" : 0 578 | }, 579 | "flush" : { 580 | "total_time_in_millis" : 51, 581 | "total_time" : "51ms", 582 | "total" : 20 583 | }, 584 | "refresh" : { 585 | "total_time_in_millis" : 0, 586 | "total_time" : "0s", 587 | "total" : 0 588 | }, 589 | "translog" : { 590 | "operations" : 0, 591 | "id" : 1357760561393 592 | }, 593 | "routing" : { 594 | "shard" : 1, 595 | "state" : "STARTED", 596 | "relocating_node" : null, 597 | "node" : "J-erllamTOiW5WoGVUd04A", 598 | "primary" : true, 599 | "index" : "wiki" 600 | }, 601 | "state" : "STARTED", 602 | "index" : { 603 | "size" : "404.2mb", 604 | "size_in_bytes" : 423851451 605 | }, 606 | "docs" : { 607 | "deleted_docs" : 0, 608 | "max_doc" : 28576, 609 | "num_docs" : 28576 610 | } 611 | }, 612 | { 613 | "merges" : { 614 | "current_size" : "0b", 615 | "current_docs" : 0, 616 | "total_size" : "0b", 617 | "current_size_in_bytes" : 0, 618 | "current" : 0, 619 | "total_time" : "0s", 620 | "total_time_in_millis" : 0, 621 | "total_docs" : 0, 622 | "total" : 0, 623 | "total_size_in_bytes" : 0 624 | }, 625 | "flush" : { 626 | "total_time_in_millis" : 14, 627 | "total_time" : "14ms", 628 | "total" : 4 629 | }, 630 | "refresh" : { 631 | "total_time_in_millis" : 0, 632 | "total_time" : "0s", 633 | "total" : 0 634 | }, 635 | "translog" : { 636 | "operations" : 0, 637 | "id" : 1357760561393 638 | }, 639 | "routing" : { 640 | "shard" : 1, 641 | "state" : "STARTED", 642 | "relocating_node" : null, 643 | "node" : "AvYWeugwQjqs0cB1vr3D-w", 644 | "primary" : false, 645 | "index" : "wiki" 646 | }, 647 | "state" : "STARTED", 648 | "index" : { 649 | "size" : "404.2mb", 650 | "size_in_bytes" : 423845459 651 | }, 652 | "docs" : { 653 | "deleted_docs" : 0, 654 | "max_doc" : 28576, 655 | "num_docs" : 28576 656 | } 657 | }, 658 | { 659 | "merges" : { 660 | "current_size" : "0b", 661 | "current_docs" : 0, 662 | "total_size" : "0b", 663 | "current_size_in_bytes" : 0, 664 | "current" : 0, 665 | "total_time" : "0s", 666 | "total_time_in_millis" : 0, 667 | "total_docs" : 0, 668 | "total" : 0, 669 | "total_size_in_bytes" : 0 670 | }, 671 | "flush" : { 672 | "total_time_in_millis" : 55, 673 | "total_time" : "55ms", 674 | "total" : 20 675 | }, 676 | "refresh" : { 677 | "total_time_in_millis" : 0, 678 | "total_time" : "0s", 679 | "total" : 0 680 | }, 681 | "translog" : { 682 | "operations" : 0, 683 | "id" : 1357760561393 684 | }, 685 | "routing" : { 686 | "shard" : 1, 687 | "state" : "STARTED", 688 | "relocating_node" : null, 689 | "node" : "Q4qgMlrETs67mUL-iGHC4A", 690 | "primary" : false, 691 | "index" : "wiki" 692 | }, 693 | "state" : "STARTED", 694 | "index" : { 695 | "size" : "404.2mb", 696 | "size_in_bytes" : 423848976 697 | }, 698 | "docs" : { 699 | "deleted_docs" : 0, 700 | "max_doc" : 28576, 701 | "num_docs" : 28576 702 | } 703 | } 704 | ] 705 | }, 706 | "merges" : { 707 | "current_size" : "0b", 708 | "current_docs" : 0, 709 | "total_size" : "0b", 710 | "current_size_in_bytes" : 0, 711 | "current" : 0, 712 | "total_time" : "0s", 713 | "total_time_in_millis" : 0, 714 | "total_docs" : 0, 715 | "total" : 0, 716 | "total_size_in_bytes" : 0 717 | }, 718 | "flush" : { 719 | "total_time_in_millis" : 935, 720 | "total_time" : "935ms", 721 | "total" : 250 722 | }, 723 | "refresh" : { 724 | "total_time_in_millis" : 0, 725 | "total_time" : "0s", 726 | "total" : 4 727 | }, 728 | "docs" : { 729 | "deleted_docs" : 0, 730 | "max_doc" : 143700, 731 | "num_docs" : 143700 732 | }, 733 | "index" : { 734 | "size" : "5.9gb", 735 | "size_in_bytes" : 6404272706, 736 | "primary_size_in_bytes" : 2134752609, 737 | "primary_size" : "1.9gb" 738 | }, 739 | "translog" : { 740 | "operations" : 0 741 | } 742 | } 743 | }, 744 | "ok" : true, 745 | "_shards" : { 746 | "failed" : 0, 747 | "successful" : 15, 748 | "total" : 15 749 | } 750 | } 751 | --------------------------------------------------------------------------------