Questions tagged [elasticsearch-rails]

Ruby and Rails integrations for Elasticsearch

Ruby and Rails integrations for Elasticsearch:

  • ActiveModel integration with adapters for ActiveRecord and Mongoid
  • Repository pattern based persistence layer for Ruby objects Active
  • Record pattern based persistence layer for Ruby models
  • Enumerable-based wrapper for search results
  • ActiveRecord::Relation-based wrapper for returning search results as records
  • Convenience model methods such as search, mapping, import, etc
  • Rake tasks for importing the data Support for Kaminari and WillPaginate pagination
  • Integration with Rails' instrumentation framework

https://github.com/elastic/elasticsearch-rails

117 questions
2
votes
1 answer

Adding boost to Elasticsearch query

I'm trying to add weight to some results from Elasticsearch. I'm currently only filtering on an 'active' boolean to grab only the published items: query: { filtered: { query: { match: { _all: params[:q] …
Joris Ooms
  • 11,880
  • 17
  • 67
  • 124
2
votes
1 answer

Elasticsearch-rails, highlights query

I'm trying to get highlights from the Elasticsearch-rails gem, but I can't get it to work. My search method: query = { query: { filtered: { query: { match: { _all: params[:q] } }, filter: { …
Joris Ooms
  • 11,880
  • 17
  • 67
  • 124
2
votes
1 answer

How to set "search_type" to "count" in elasticsearch-rails?

Here's the query I'd like to get working with elasticsearch-rails. (The query works in Sense). My goal is to return all the buckets for items that have a person whose name begins with the letter B. My first stumbling block is that I can't figure out…
Bailey Smith
  • 2,853
  • 4
  • 27
  • 39
1
vote
1 answer

Testing Rails Elasticsearch implementation, waiting for refresh_index to finish before searching

I am having a great deal of issues with "race conditions" in my specs for Elasticsearch testing. Sometimes my tests pass, sometimes they don't, sometimes they find X number of results and sometimes they find a different number of results. This all…
rii
  • 1,578
  • 1
  • 17
  • 22
1
vote
1 answer

Indexing Method on Object Returned From Method - Elasticsearch

I'm using the elasticsearch-rails gem with Rails 6. I'm trying to index the return value of a carrierwave function asset_host. I can index the file function, but I'm not sure of the syntax to index the asset_host method on the Uploader object…
Cannon Moyer
  • 3,014
  • 3
  • 31
  • 75
1
vote
0 answers

How to call _count from elasticsearch-rails?

As the title says, I want to make the following query from rails with the elasticsearch-rails gem. curl -XGET "localhost:9200/my_index/_count?pretty" -H 'Content-Type: application/json' -d' { "query": { "term": { "my_field": 12 } …
phil
  • 4,668
  • 4
  • 33
  • 51
1
vote
0 answers

Is there a better way to design data structure for storing inventory for each shop?

Facing with a challenge in redesigning the way to store the data in elasticsearch(version 6), The current architecture looks like this, all the master products, product items, category, and brands are stored in Postgresql. Then add shop's inventory…
1
vote
1 answer

Uninstall elasticsearch from /usr/local/var and install another version on MacOSX

I was trying to downgrade elasticsearch from 6.8.4 to 5.6 on my Mac machine. But somehow I mess with the existing installation of 6.8.4 and now neither I am able to fix the current installed version nor I am able to install 5.6 Details: I had 6.8.4…
Puneet Pandey
  • 541
  • 2
  • 6
  • 23
1
vote
1 answer

Incorrect Results With Punctuation - ElasticSearch

I have a name field that is indexed using the english analyzer that contains part names (also tried the standard analyzer). The problem I have is some of my titles contain punctuation, some do not. Also, some of my queries contain punctuation and…
Cannon Moyer
  • 3,014
  • 3
  • 31
  • 75
1
vote
2 answers

Setting keyword field in elasticsearch

I upgraded Rails from 4 to 5.2 and have also updated elasticsearch from 2.4 to 6.8. The following is the error I'm getting. [400] {"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"Fielddata is disabled on text fields by default.…
1
vote
1 answer

Using scroll api via elasticsearch-model

For the life of me I can't find any reference to using the ElasticSearch scroll api from within Ruby on Rails and the elastisearch-model (or rails or dsl) gem. The only thing they do reference in the docs is calling scroll directly on the client,…
1
vote
1 answer

Elasticsearch 6.3.2 terms match empty array "plus" others

In my database, a post can have zero (0) or more categories represented as an array. When I do the query, to look within those categories, passing some values: { "query": { "bool": { "should": { "terms": { "categories":…
1
vote
0 answers

Many to Many ElasticSearch - Rails

I'm using the elasticsearch-rails gem and I'm trying to search a model that has a many to many relationship with another model. Here are my models: Customer has_and_belongs_to_many :locations Location has_and_belongs_to_many :customers I…
Cannon Moyer
  • 3,014
  • 3
  • 31
  • 75
1
vote
1 answer

ElasticSearch - Pass Array of Terms to Filter

I have a query where I would like to pass a dynamic amount of terms to the filter. Is there anyway to pass this as an array? I've tried several different things but always end up with a malformed request error from elasticsearch. I'm using Ruby on…
1
vote
2 answers

Add Filter To ElasticSearch Query

I'm trying to create a query where the user can search for ES documents where the brand field is equal to some string. Here is the query I currently have that works but has no filtering. I'm using elasticsearch-rails with Ruby on Rails. @products =…