Questions tagged [elastic4s]

Elastic4s is mostly a wrapper around the standard Elasticsearch Java client with the intention of creating a concise, idiomatic, reactive, type safe DSL for applications in Scala that use Elasticsearch.

Elastic4s is mostly a wrapper around the standard Elasticsearch Java client with the intention of creating a concise, idiomatic, reactive, type safe DSL for applications in Scala that use Elasticsearch. The Java client, which can of course be used directly in Scala, is more verbose due to Java's nature. Scala lets us do better.

Elastic4s's DSL allows you to to construct your requests programmatically, with syntactic and semantic errors manifested at compile time, and uses standard Scala futures to enable you to easily integrate into your existing asynchronous workflow. The aim of the DSL is that requests are written in an SQL-like way, while staying true to the Java API or Rest API.

Elastic4s supports Scala collections so you don't have to do tedious conversions from your Scala domain classes into Java collections. It also allows you to index documents directly without having to extract and set fields manually - eg from a case class, a JSON document, or a Map (or a custom source). Due to its typesafe nature, it is easy to see what operations are available for any request type, because your IDE can use type information to show what methods are available.

161 questions
2
votes
1 answer

elastic4s with Amazon Elasticsearch Service

I'm using elastic4s in my scala project to communicate with ElasticSearch. For development I started a local node and everything is working fine. For production, I would like to use Amazon Elasticsearch Service. I've configured that service and…
user3346601
  • 1,019
  • 1
  • 11
  • 18
2
votes
1 answer

Getting zero results in search using elastic4s

This is a small code I am using to do a simple search: import com.sksamuel.elastic4s.{ElasticsearchClientUri, ElasticClient} import com.sksamuel.elastic4s.ElasticDsl._ import org.elasticsearch.common.settings.ImmutableSettings object Main3 extends…
Animesh Pandey
  • 5,900
  • 13
  • 64
  • 130
2
votes
1 answer

Search in Multiple Indexes

When I do a search is it possible to search across multiple indexes? I know we could create an alias, but I would rather not have to do that for my given use case. the "search in index1" works great. Was just hoping I could do something like…
scarpacci
  • 8,957
  • 16
  • 79
  • 144
2
votes
1 answer

How to make elastic4s store _timestamp field?

I'm able to enable timestamp on a mapping like this : "someType" as ( "someField" typed StringType ) timestamp true But to be able to retrieve it when searching using "fields": ["_timestamp"] it also needs to have store attribute set to true.…
lisak
  • 21,611
  • 40
  • 152
  • 243
2
votes
2 answers

How put index with mapping template to elastic search with elastic4s?

I want create index with dynamic template and turn analyzing off for string fields. I have created query for elastic search, but how to translate it into elastic4s statments? (version elastic4s 1.3.x is preffered) The statement is: PUT /myIndex { …
Cherry
  • 31,309
  • 66
  • 224
  • 364
2
votes
1 answer

elastic4s - search in multiple fields

I'm using the elastic4s client for my scala elastic search and trying to search on multiple fields something like: "query": { "match": { "_all": { "query": "SomeTermToMatch", "operator": "and" } } } I've tried: query { '_all',…
griffon vulture
  • 6,594
  • 6
  • 36
  • 57
2
votes
1 answer

Elasticsearch Scripts to add element into an array

I am working on ElasticSearch in a scala project. I am using elastic4s as the client. I am trying to add elements to a document, from an iterator one by one. while (iterator.hasNext) { counter +=1 client.execute { update id reportID in…
igalbenardete
  • 207
  • 2
  • 12
2
votes
1 answer

elastic4s query search function score

how I can create the query with client elastic4s scala? I call using marvel/sense GET /business/_search { "query": { "function_score": { "query": { "match": { "name": "my text" } }, "script_score":…
2
votes
1 answer

Exception when using elastic4s with elastic-search and spray-routing

I'm trying to write a little REST api using Scala, Spray.io, Elastic4s and ElasticSearch. My ES instance is running with default parameters, I just changed the parameter network.host to 127.0.0.1. Here is my spray routing definition package…
ylos
  • 522
  • 1
  • 6
  • 16
2
votes
3 answers

elastic4s and play framework 2.2.1

i'm trying to index some data to elastic search by using the elastic4s API and play framework I'm basically calling this method from the controller def test(){ val client = ElasticClient.local client.execute { create index "bands" } client…
MIkCode
  • 2,655
  • 5
  • 28
  • 46
1
vote
0 answers

Index to Elasticsearch with script using Elastic4s - Scala

I'm trying to merge the payload from a consumer with an existing document in my Elasticsearch index using elastic4s 7.17.2. However, when I execute the query with the provided script, I'm getting an error from Elasticsearch: [ { "itemId" : 0, "id"…
1
vote
1 answer

How to use search_after in elastic4s

i'm trying to get some data based on query with elastic4s in scala using search_after because i have more then 10 000 items. I'm trying something like this: client.execute( search(index).query(q).searchAfter(id).from(start).limit(limit) ) But…
1
vote
1 answer

How to add a Rank Feature type field to an Index in scala?

def createCompanyAutoCompleteIndex(indexName: String, host: String, port: Int = defaultPort, shds: Int = defaultShards): Unit = { client(host, port).execute { createIndex(indexName).shards(shds).mappings { …
1
vote
0 answers

scriptScoreQuery implementation in elastic4s

I use elastic 7.6 and Elastic4s client 7.6.0 I am working on a feature in that requires to change the ‘_score‘ of a subQuery in a bigger one: in all my big query would look something like this : {"query": { "function_score": { "query":…
1
vote
1 answer

sbt unable to import two elasticsearch libraries of different version in project

I am trying to connect with two elasticsearch clusters using scala code and query elasticsearch from them. using following libraries and code in build.sbt of scala project: libraryDependencies +="org.elasticsearch" % "elasticsearch" %…
1 2
3
10 11