Hello everyone!

We have been investing plenty of personal time and energy for many years to share our knowledge with you all. However, we now need your help to keep this blog running. All you have to do is just click one of the adverts on the site, otherwise it will sadly be taken down due to hosting etc. costs. Thank you.

Commands below are just a few basic examples that you can use against elasticsearch index.


Mapping


This mapping is dedicated to a symfony application and depends on FOSElasticaBundle.


fos_elastica:
clients:
default: { host: 127.0.0.1, port: 9203 }
indexes:
post_index:
client: default
index_name: post_dev
types:
post:
mappings:
id:
type: string
index: not_analyzed
title:
type: string
analyzer: english
fields:
raw:
type: string
index: not_analyzed
description:
type: string
analyzer: english
fields:
raw:
type: string
index: not_analyzed
year:
type: integer
index: not_analyzed
price:
type: double
index: not_analyzed
is_published:
type: boolean
index: not_analyzed
created_at:
type: date
index: not_analyzed
persistence:
driver: mongodb
model: Application\MongoBundle\Document\Post
finder: ~
provider: ~
listener: ~

Commands


# Check currently running ES server details
$ curl -X GET http://127.0.0.1:9203

# Show index mapping information
$ curl -X GET 127.0.0.1:9203/post_dev?pretty
$ curl -X GET 127.0.0.1:9203/_mapping/post?pretty

# Run an ES query in terminal
$ curl -s -XGET 127.0.0.1:9203/post_dev/_search -d '{json query goes here}'

# Get some sample data from ES index
$ curl -XGET 127.0.0.1:9203/post_dev/_search?pretty=1

# Delete index
$ curl -XDELETE 'http://127.0.0.1:9203/post_dev'

# Create an index
$ curl -XPUT 'localhost:9200/my_new_index?pretty'

# List all indexes in ES server
$ curl 127.0.0.1:9200/_cat/indices?v