Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get started with Elastic Search using scala client

Hi i am new in Elastic Search and i want to use it with scala so i found some codes examples on github, but there was very complex examples were given as for a beginner I spend my whole day in trying to understand this tutorial but at the end i am confused how to start this is,its very complex to understand same as with other Scala client examples

  1. https://github.com/scalastuff/esclient
  2. https://github.com/bsadeh/scalastic
  3. https://github.com/gphat/wabisabi also i tried this but it contains error and i posted it here as well https://stackoverflow.com/questions/27145015/scalagetstatuscode-getresponsebody-is-not-a-member-of-dispatch-future

All these examples are very complex for a new learner like me as i go through first chapter of Elastic Search from its guide then I want to do these same things pro-grammatically with Scala.Please suggest me some starting point from where can i start learning and also there is a request do not mark this question as nonconstructive first i tried myself after then i am posting this question,Please i need help i want to learn elastic search using scala

like image 830
swaheed Avatar asked Nov 29 '14 14:11

swaheed


People also ask

What is Elasticsearch client?

Elasticsearch is a distributed search and analytics engine built on Apache Lucene. Since its release in 2010, Elasticsearch has quickly become the most popular search engine and is commonly used for log analytics, full-text search, security intelligence, business analytics, and operational intelligence use cases.

How do you test Elasticsearch?

Windows users can download Elasticsearch as a ZIP file. Simply extract the contents of the ZIP file, and run bin/elasticsearch. bat to start up an instance. Note that you'll need Java installed and configured on your system in order for Elasticsearch to run properly.


1 Answers

The Elastic4s project contains, near the top of the readme, a simple example on how to use the driver. This example is a complete Scala program that you can execute.

import com.sksamuel.elastic4s.ElasticClient
import com.sksamuel.elastic4s.ElasticDsl._

object Test extends App {

  val client = ElasticClient.local

  // await is a helper method to make this operation sync instead of async
  // You would normally avoid doing this in a real program as it will block
  client.execute { index into "bands/artists" fields "name"->"coldplay" }.await

  val resp = client.execute { search in "bands/artists" query "coldplay" }.await
  println(resp)

}

If this is too complicated, then that is not because the Scala client is too complicated, but because you don't yet understand enough about Elasticsearch or Scala. The Scala client you are looking at is a typical DSL so it uses some Scala tricks that make it nice to use as a client, but not necessarily easy to to understand under the covers.

Here are some good links to understanding Elasticsearch:

  • http://spinscale.github.io/elasticsearch/2012-03-jugm.html#/20
  • http://exploringelasticsearch.com/
  • http://joelabrahamsson.com/elasticsearch-101/
  • http://www.slideshare.net/karmi/your-data-your-search-elasticsearch-euruko-2011

Before you use any of the Scala drivers, you should at least understand the basic concepts of an index/type, the query DSL, and what a node is in Elasticsearch. It might also be helpful to look at the JSON that you can send with the HTTP interface as that is a bit easier to see what is going on, because the Elasticsearch docs can be heavy going at first.

like image 83
sksamuel Avatar answered Oct 20 '22 00:10

sksamuel