Playing with ElasticSearch (ES) lately. Few notes on that.
- Index name only allows filename chars. For example, space is not allowed. So “index1” is ok, “index 1” not.
- In theory type allows space (or so I think) but does that not work with curl so forget it. Better stick to basic chars of alphanumeric and underscore. So “type1” and “type_1” are OK, “type 1” is not.
- Curl allows to define file to load with the character “at”, that is “@”. See examples below.
- Default port where ES provides its REST interface is 9200, can be set in config.yml.
- When updating to new ES: download and extract new version, copy over data dir, start. Hope it works, I have no idea if this worked or not.. 🙂
Most commands can be sent using HTTP commands with curl. For the GET commands, a regular browser should work as well. Some of the relevant commands so far:
- list indices: curl ‘localhost:9200/_cat/indices?v’
- get item: curl -XGET ‘http://localhost:9200/INDEXNAME/TYPENAME/OBJECTID’
- bulk upload: curl -s -XPOST localhost:9200/_bulk –data-binary @FILENAME
- delete index: curl -XDELETE ‘http://localhost:9200/INDEXNAME/’
- stats for docs in specific index: curl localhost:9200/INDEXNAME/_stats/docs/
- index mappings (schema): curl -XGET ‘http://localhost:9200/INDEXNAME/_mapping’
- type mappings: curl -XGET ‘http://localhost:9200/INDEXNAME/_mapping/TYPENAME’
- create mapping: curl -XPOST ‘http://localhost:9200/INDEXNAME’ –data-binary @FILENAME
By appending “;echo” at the end, the results will be prettier as they will end in a newline.