elastic4s

creating settings of index using elastic4s

杀马特。学长 韩版系。学妹 提交于 2020-02-06 08:01:11
问题 I have some class: class SomeClass(val client: ElasticClient, val config: Config, val configName: String)(implicit val ec: ExecutionContext) extends ElasticSearchRepositoryWrapper[AnotherClass]{ override def mapping: Option[MappingDefinition] = Some( properties( KeywordField("id"), TextField("name").fielddata(true).analyzer("ngram_analyzer"), KeywordField("lang"), BasicField("order", "long"), ... ) ) I'm creating an index with repository.createIndexIfNotExists() using this mapping. Now I must

Elastic4s - finding multiple exact values for one term

元气小坏坏 提交于 2020-01-16 04:10:01
问题 I'm trying to filter a term to be matching one of the values in an array. relaying on the ES https://www.elastic.co/guide/en/elasticsearch/guide/current/_finding_multiple_exact_values.html GET /my_store/products/_search { "query" : { "filtered" : { "filter" : { "terms" : { "price" : [20, 30] } } } } } I tried this: val res = ESclient.execute { search in "index" query { filteredQuery query { matchall } filter { termsFilter("category", Array(1,2)) } } But got an error from ES. How can I do that

Elasticsearch - how to append term?

99封情书 提交于 2020-01-13 05:52:54
问题 Is there a way to append term into an array of values? For example if my document looks like this: { "items": ["item1", "item2", "item3"] } I want to append "item4" and "item5" to it. I must do it in 2 queries? one to load the current list of values, and on to update that list? or is there more elegant way that will let me append those items in one query? I am trying to do it with elastic4s like this: client.execute(ElasticDsl.update id id in indexName / documentType script { script(s"ctx.

org.elasticsearch.client.transport.NoNodeAvailableException: None of the configured nodes are available: []

谁都会走 提交于 2019-12-23 16:38:59
问题 I am running ElasticSearch on Docker which is available locally as $ curl http://192.168.99.100:9200/?pretty { "status" : 200, "name" : "Collector", "cluster_name" : "elasticsearch", "version" : { "number" : "1.4.4", "build_hash" : "c88f77ffc81301dfa9dfd81ca2232f09588bd512", "build_timestamp" : "2015-02-19T13:05:36Z", "build_snapshot" : false, "lucene_version" : "4.10.3" }, "tagline" : "You Know, for Search" } I am using Elastic4s, for connecting to ElasticSearch , I tried following approach,

Elasticsearch scala elastic4s settings from property file

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-11 06:43:09
问题 is there a way how to pass settings to elastic4s from property file? The following way works but it is not flexible in munltienvironment: val settings = ImmutableSettings.settingsBuilder().put("cluster.name","elasticsearch").build() val client = ElasticClient.remote(settings, "154.86.209.242" -> 9300, "153.89.219.241" -> 9300) I tried java configuration file elasticsearch.yaml as mantioned in java doc but that doesn't work. Any suggestion here? 回答1: You can do this using the same method you

Getting zero results in search using elastic4s

妖精的绣舞 提交于 2019-12-11 02:42:07
问题 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 App { val uri = ElasticsearchClientUri("elasticsearch://localhost:9300") val settings = ImmutableSettings.settingsBuilder().put("cluster.name", "elasticsearch").build() val client = ElasticClient.remote(settings, uri) if (client.exists("bands")

not found value index error on elastic4s

你说的曾经没有我的故事 提交于 2019-12-10 21:15:48
问题 im trying to index some data to elastic search by using the elastic4s API but im getting compile error not found: value index this is the code , later on i will map the js object fields to the elastic search fields , but for now i just want to index a test case import com.sksamuel.elastic4s._ def indexComment(commentList: List[JsObject]) { val client = ElasticClient.local for (comment <- commentList) { val id = comment.\("id").as[String] client.execute { index into "posts/test" id id.toString

How track json request sent to Elasticsearch via elastic4s client?

為{幸葍}努か 提交于 2019-12-10 15:26:40
问题 Say that I use such code: ElasticClient client = ... client.execute{search in "places"->"cities" query "paris" start 5 limit 10} How to see what json request was been sent to Elasticsearch? 回答1: In Elastic4s 1.6.2 you can use the show typeclass on a number of requests to get the JSON equivilent. It's pretty straightforward. val req = search in "index" / "type" query "kate bush" logger.debug(s"Search request ${req.show}") The .show method will render JSON output. It works on most of the

Dynamic ElasticSearch mapping using Elastic4s

房东的猫 提交于 2019-12-10 14:46:12
问题 I have a document that I want to index on elasticSearch, this document contains some dynamic keys that I can not know in advance, like "spanish" or "french" in the following example "contents": { "title": { "spanish": "Hola amigos", "french" : "Bonjour les amis" } } I'm using the elastic4s DSL in order to make my mapping (Via the createIndex DSL), but I can not find how to create, with this library, a dynamic mapping based on the "match" option ( like suggested here), in order to specify a

Elasticsearch - how to append term?

依然范特西╮ 提交于 2019-12-04 17:54:34
Is there a way to append term into an array of values? For example if my document looks like this: { "items": ["item1", "item2", "item3"] } I want to append "item4" and "item5" to it. I must do it in 2 queries? one to load the current list of values, and on to update that list? or is there more elegant way that will let me append those items in one query? I am trying to do it with elastic4s like this: client.execute(ElasticDsl.update id id in indexName / documentType script { script(s"ctx._source.items += tag").params(Map("tag"->"item4")) }) In order to use the above code snippet, I need to