Giter Site home page Giter Site logo

scalastic's Introduction

Scalastic

Scala driver for ElasticSearch

Contributors

About

Scalastic is an interface for ElasticSearch, designed to provide more flexible and Scala-esque interface around the native elasticsearch Java API.

Scalastic has been developed and tested against elasticsearch 1.9.x+.

Way cool, but how do I use it?

in general, look at the scalatest source for usage examples ...

the main dude is the Indexer: import com.traackr.elasticsearch._ val indexer = Indexer.

just about every Indexer api call has these forms: indexer. // a blocking call indexer.send_ // async call indexer.prepare_ // get the builder and tailor it all to your heart's content

api-calls employ named parameters and provide default values; you only need to provide what differs.

Creating an Indexer (connecting to an elastic cluster)

using node-based access:

val indexer = Indexer.local.start
val indexer = Indexer.using(settings) // String or Map
val indexer = Indexer.at(node)

using a transport client:

val indexer = Indexer.transport(settings = Map(...), host = "...")

Indexing

val mapping = """
{
  "type1": {
    "properties" : {
	  "from" : {"type": "ip"},
	  "to" : {"type": "ip"}		
    }
  }
}
"""
indexer.createIndex("index1", settings = """{"number_of_shards":1}""")
indexer.waitTillActive()
indexer.putMapping(indexName, "type1", mapping)
indexer.index(indexName, "type1", "1", """{"from":"192.168.0.5", "to":"192.168.0.10"}""")
indexer.refresh()
  • for an atomic total-reindexing operation, see:

    indexer.reindexWith

  • for syncing with indexing operations on a type (index/delete), see the family of methods in the WaitingForGodot trait:

    indexer.waitTillCount[AtLeast | Exactly | AtMost]

Searching

indexer.search(query = boolQuery
  .must(rangeQuery("from") lt "192.168.0.7")
  .must(rangeQuery("to") gt "192.168.0.7"))

or:

val response = indexer.search(indices=List(index1, indexN), query = some_narly_query, from=100, size=25, etc. etc.)

Testing

  • try mixing in the UsingIndexer trait

Building

  • sbt 0.11.2
  • Maven 3.0.4

Installing

scalastic's People

Contributors

bsadeh avatar cldellow avatar gip avatar

Watchers

 avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.