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
22
votes
1 answer

How can I use ElasticSearch-Rails query dsl to return related relationships

I am new to ElasticSearch, but need to use it to return a list of products. Please do not include answers or links to old answers which reference the deprecated tire gem. gemfile ruby '2.2.0' gem 'rails', '4.0.3' gem 'elasticsearch-model', '~>…
11
votes
1 answer

Elasticsearch Rails as_indexed_json vs mappings

I am using the Elasticsearch Rails gem and I am using two things in my model: def as_indexed_json end and settings index: { number_of_shards: 1 } do mapping dynamic: 'false' do indexes :id indexes :customer do …
Mike Riley
  • 282
  • 3
  • 20
10
votes
6 answers

Scope Elasticsearch Results to Specific Ids

I have a question about the Elasticsearch DSL. I would like to do a full text search, but scope the searchable records to a specific array of database ids. In SQL world, it would be the functional equivalent of WHERE id IN(1, 2, 3, 4). I've been…
mindtonic
  • 1,385
  • 2
  • 14
  • 24
7
votes
2 answers

Elasticsearch::Transport::Transport::Errors::NotFound ([404] {"error":{"root_cause":[{"type":"index_not_found_exception"

Not sure while working in local environment with elasticsearch i m getting this weird error, any help would me appreciated. thanks Elasticsearch::Transport::Transport::Errors::NotFound ([404] …
Anand
  • 6,457
  • 3
  • 12
  • 26
7
votes
0 answers

VersionConflictEngineException after upgrade to Rails 4.2.5.1

I'm getting this exception from time to time after updating Rails to 4.2.5.1 and updating a user document Elasticsearch::Transport::Transport::Errors::Conflict: [409] {"error":"VersionConflictEngineException[[users][0] [user][1]: version …
5
votes
3 answers

ElasticSearch Rails resource_already_exists_exception when running tests

I'm trying to run one of my tests, which makes a search, trying to assert the inclusion of records in the search result, but in the meantime, I'm receiving a Elasticsearch::Transport::Transport::Errors::BadRequest…
5
votes
0 answers

Multiple Aggregations on same level in Elasticsearch-rails

I am trying to perform multiple aggregations at the same level with ElasticSearch using the elasticsearch-rails and elasticsearch-model gems. In the query hash that I am generating, I have the following - def query_hash(params, current_person =…
Michael Victor
  • 861
  • 2
  • 18
  • 42
5
votes
1 answer

adding index for an attribute of jsonb field in elasticsearch rails

I am a beginner in elasticsearch and I want to add an index for the field inside a jsonb field I am having. This is not a nested relationship. I am having table payload with fields id (integer),user_id(integer),data(jsonb). Sample jsonb value is…
5
votes
2 answers

How to fetch a document by its ID in elasticsearch rails

I see in the elasticsearch docs you can fetch a document by its ID. Is there any equivalent in elasticsearch rails? I'm feeding by API with "as_indexed_json" and it's a somewhat expensive query, I'd like to return ths JSON straight out of…
jdkealy
  • 4,807
  • 6
  • 34
  • 56
4
votes
1 answer

How do you eager-load records with Elasticsearch::Model.search() across multiple models?

Using the elasticsearch-rails/elasticsearch-model gems. I know you can do the following with the proxy on a single model: MyModel.__elasticsearch__.search(search_hash).records.includes(:my_association) I need to search across similar models which…
4
votes
2 answers

Limit the Elasticsearch results count in Rails

I'm running Rails with Elasticsearch using the elasticsearch-rails and will_paginate gems and things are working great. The only problem I'm having is that my records count has grown over 10.000 which gives the error "Result window is too large,…
4
votes
1 answer

Elasticsearch-rails : response is empty at times, second request it returns proper response

New to elasticsearch-rails. It is acting werid. When I call my API for the first time, at times, it responds with empty array but calling the same API again, returns proper response. API Output - For the first time API Output- Second time My…
Disha
  • 776
  • 9
  • 19
4
votes
1 answer

Nested associations - elasticsearch-rails or chewy?

I have a Rails app with ActiveRecord models that have associations between them. For the sake of simplicity, lets say I have exactly the same DB schema as in -…
Anton Antonov
  • 1,217
  • 2
  • 14
  • 21
4
votes
2 answers

How do you filter a query with elasticsearch-rails gem?

I have a Piece model with a boolean attribute of published. I want the search results to only contain Pieces that are plublished: true. My index action for the PiecesController is: def index @list = params[:list] @sort = params[:sort] if…
Cu1ture
  • 1,273
  • 1
  • 14
  • 29
3
votes
2 answers

Rails __elasticsearch__.create_index! "Root mapping definition has unsupported parameters(mapper_parsing_exception)"

I have trouble with elasticsearch-rails, when I'm using Business.__elasticsearch__.create_index! I'm getting an error: {"error":{"root_cause":[{"type":"mapper_parsing_exception","reason":"Root mapping definition has unsupported parameters: …
1
2 3 4 5 6 7 8