elastic search

Download Elastic search

If you can't read please download the document

Upload: nexthoughts-technologies

Post on 17-Jan-2017

112 views

Category:

Technology


1 download

TRANSCRIPT

Elastic Search

Elasticsearchisareal-time distributedsearchandanalytics engine.

Elasticsearchtoprovidefull-textsearch.

Elasticsearchisanopen-source searchengine builton top of Apache Lucene.

Lucene creates the inverted index that isused for searching.

Build Config.groovy

runtime ':elasticsearch:0.0.4.6'

Config.groovy

environments { development { elasticSearch { client.mode = 'local' index.name = 'event' cluster.name = 'elasticsearch' datastoreImpl = 'hibernateDatastore';

}}

How to configure in Domainstatic searchable = true

Custom Mapping static searchability = {

}For Excluding Propertystatic searchable = { except = 'someUselessField' }

Analyzer

Simple Analyzer

An analyzer of type simple that is built using a Lower Case Tokenizer.Whitespace AnalyzerAn analyzer of type whitespace that is built using a Whitespace Tokenizer.

Keyword AnalyzerAn analyzer of type keyword that "tokenizes" an entire stream as a single token., it might make more sense to simply mark the field as not_analyzed.

Controller

def eventSearch = { String search -> def result = Event.search(search) Integer countHits = Event.countHits(search) List list = [] println("===========FOUND==========$ {result.total}") result.searchResults.eachWithIndex { i, index -> println('''========i.result========='') }

Cluster

A cluster is a collection of one or more nodes (servers) that together holds your entire data and provides federated indexing and search capabilities across all nodes. A cluster is identified by a unique name which by default is "elasticsearch".

Node

A node is a single server that is part of your cluster, stores your data, and participates in the clusters indexing and search capabilities.A node can be configured to join a specific cluster by the cluster name.each node is set up to join a cluster named elasticsearch.

Shard

Elasticsearch provides the ability to subdivide your index into multiple pieces called shards. When you create an index, you can simply define the number of shards that you want.By default, each index in Elasticsearch is allocated 5 primary shards and 1 replica which means that if you have at least two nodes in your cluster, your index will have 5 primary shards and another 5 replica shards (1 complete replica) for a total of 10 shards per index.

Replica

In a network/cloud environment where failures can be expected anytime, it is very useful and highly recommended to have a failover mechanism in case a shard/node somehow goes offline or disappears for whatever reason. To this end, Elasticsearch allows you to make one or more copies of your indexs shards into what are called replica shards, or replicas for short.

Filter Search

POST /_search{ "query": { "filtered": { "query": { "query_string": { "query": "drama" } }, "filter": { "term": { "year": 1962 } } }}

References

https://www.elastic.co/guide/index.html

http://joelabrahamsson.com/elasticsearch-101/

Thank You!!!