FAQ Database Discussion Community


Getting zero results in search using elastic4s

scala,elasticsearch,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 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").await.isExists()) { println("Index already...

Elastic4s client bulk operation error

scala,elastic4s
I am trying to use scala elstic4s client to index new documents into my elasticsearch cluster but I am having a compilation problem with the types. Following the documentation and the examples found in the web, the syntax looks like: Client instantiation: val settings = ImmutableSettings.settingsBuilder().put("cluster.name", Configuration.elasticsearchClusterName).build() val uri =...

Is `scan` parameter enabled during scroll in elastic4s?

scala,scroll,elasticsearch,elastic4s
Here (at the end of table) example about using scrolls in elastic4s but I can not see any API to set scan parameter. Is it enabled by default or should be used with some hooks? By the way Or scan parameter is enabled by default during scrolling in elasticsearch?...

Elastic4s - how to express “matched_fields”

elastic4s
I want to implement the following query in Elastic4s. Don't see any way to implement the matched_fields clause in the highlighter. Any help? { "query": { "multi_match": { "type": "most_fields", "query": "hello world", "fields": [ "text", "text.human" ] } }, "highlight": { "order": "score", "fields": { "text": { "matched_fields": [...

How to make elastic4s store _timestamp field?

scala,elasticsearch,elastic4s
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. But if I do this : "someType" as...

Elasticsearch Scripts to add element into an array

scala,groovy,elasticsearch,elastic4s
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 "reports/report" script "ctx._source.elasticData += output" params Map("output" ->...

Real difference between curly braces and parenthesis in scala

scala,elastic4s
After using Scala for a while and reading about all over the place and especially here I was sure I know when to use curlies. as a rule of thumb if I want to pass a block of code to be executed i will use curly braces. how ever this...

Why ElasticSearch Java Client index Future completes before the record is searchable?

elasticsearch,elastic4s
I'm using elastic4s client that returns a Future in response to index request and when that future completes I still have to do Thread.sleep(1000) before I can query for that indexed record. Mostly it is exactly 1 second. Is there an elasticsearch setting that I can change so that when...

How do I implement a PatternAnalyzer in elastic4s and elasticsearch to exclude result with a certain field

elasticsearch,playframework,elastic4s
I'm trying to perform a query on my index and get all reviews that do NOT have a reviewer with a gravatar image. To do this I have implemented a PatternAnalyzerDefinition with a host pattern: "^https?\\:\\/\\/([^\\/?#]+)(?:[\\/?#]|$)" that should match and extract host of urls like: https://www.gravatar.com/avatar/blablalbla?s=200&r=pg&d=mm becomes: www.gravatar.com The mapping:...

How to write mapping/settings for an index using elastic4s?

scala,elasticsearch,elastic4s
PUT /new_index/ { "settings": { "index": { "type": "default" }, "number_of_shards": 5, "number_of_replicas": 1, "analysis": { "filter": { "ap_stop": { "type": "stop", "stopwords_path": "stoplist.txt" }, "shingle_filter" : { "type" : "shingle", "min_shingle_size" : 2, "max_shingle_size" : 5, "output_unigrams": true } }, "analyzer": { "aplyzer": { "type": "custom", "tokenizer": "standard", "filter":...

elastic4s query document with list of keys

elastic4s
I'm trying to retrieve records from elastic search repo. And my method looks like this def findPartialFieldWithId(id: String, path: String): Future[SearchResponse] = { client.execute { search in IndexType query { termQuery("_id", id) } sourceInclude (path) } } But if id is a list of String instead of String, what DSL...

Elastic4s - finding multiple exact values for one term

scala,elasticsearch,elastic4s
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...