tire

How to prevent attachments from being stored in _source with Elasticsearch and Tire?

可紊 提交于 2019-12-04 10:03:04
I've got some PDF attachments being indexed in Elasticsearch, using the Tire gem. It's all working great, but I'm going to have many GB of PDFs, and we will likely store the PDFs in S3 for access. Right now the base64-encoded PDFs are being stored in Elasticsearch _source, which will make the index huge. I want to have the attachments indexed, but not stored, and I haven't yet figured out the right incantation to put in Tire's "mapping" block to prevent it. The block is like this right now: mapping do indexes :id, :type => 'integer' indexes :title indexes :last_update, :type => 'date' indexes

Symbols in query-string for elasticsearch

雨燕双飞 提交于 2019-12-04 02:01:42
I have "documents" (activerecords) with an attribute called deviations. The attribute has values like "Bin X" "Bin $" "Bin q" "Bin %" etc. I am trying to use tire/elasticsearch to search the attribute. I am using the whitespace analyzer to index the deviation attribute. Here is my code for creating the indexes: settings :analysis => { :filter => { :ngram_filter => { :type => "nGram", :min_gram => 2, :max_gram => 255 }, :deviation_filter => { :type => "word_delimiter", :type_table => ['$ => ALPHA'] } }, :analyzer => { :ngram_analyzer => { :type => "custom", :tokenizer => "standard", :filter =>

Facet Troubles with Elasticsearch on Query

痴心易碎 提交于 2019-12-03 20:49:29
When adding a term to my query instead of a filter I am getting 0 facets. FYI I am using the tire gem with Ruby. Here is my model code with its mapping: class Property < ActiveRecord::Base include Tire::Model::Search include Tire::Model::Callbacks has_and_belongs_to_many :tags mapping do indexes :id, type: 'integer' indexes :status indexes :refno, type: 'integer' indexes :name, :analyzer => 'snowball', :boost => 100 indexes :description indexes :tags, type: 'object', properties: { name: { type: 'multi_field', fields: { name: { type: 'string', analyzer: 'snowball' }, exact: { type: 'string',

Elasticsearch char_filter replace any character with whitespace?

删除回忆录丶 提交于 2019-11-30 01:56:57
问题 I'm using elasticsearch for my Ruby on Rails application. I want to use char_filter to replace some characters with whitepace. In tutorial of elasticsearch it says something like: "mappings" : ["ph=>f", "qu=>q"] I've tried the following: "mappings" : ["ph=>\s", "qu=>\s"] However it does not seem to work. Any ideas guys? 回答1: You can use \uXXXX notation for spaces: "mappings" : ["ph=>\s", "qu=>\\u0020"] 来源: https://stackoverflow.com/questions/15501517/elasticsearch-char-filter-replace-any

Multi-field, multi-word, match without query_string

让人想犯罪 __ 提交于 2019-11-29 21:50:18
I would like to be able to match a multi word search against multiple fields where every word searched is contained in any of the fields, any combination. The catch is I would like to avoid using query_string. curl -X POST "http://localhost:9200/index/document/1" -d '{"id":1,"firstname":"john","middlename":"clark","lastname":"smith"}' curl -X POST "http://localhost:9200/index/document/2" -d '{"id":2,"firstname":"john","middlename":"paladini","lastname":"miranda"}' I would like the search for 'John Smith' to match only document 1. The following query does what I need but I would rather avoid

Multi-field, multi-word, match without query_string

只谈情不闲聊 提交于 2019-11-28 17:46:23
问题 I would like to be able to match a multi word search against multiple fields where every word searched is contained in any of the fields, any combination. The catch is I would like to avoid using query_string. curl -X POST "http://localhost:9200/index/document/1" -d '{"id":1,"firstname":"john","middlename":"clark","lastname":"smith"}' curl -X POST "http://localhost:9200/index/document/2" -d '{"id":2,"firstname":"john","middlename":"paladini","lastname":"miranda"}' I would like the search for

Analyzers in elasticsearch

你说的曾经没有我的故事 提交于 2019-11-28 16:31:01
I'm having trouble understanding the concept of analyzers in elasticsearch with tire gem. I'm actually a newbie to these search concepts. Can someone here help me with some reference article or explain what actually the analyzers do and why they are used? I see different analyzers being mentioned at elasticsearch like keyword, standard, simple, snowball. Without the knowledge of analyzers I couldn't make out what actually fits my need. Let me give you a short answer. An analyzer is used at index Time and at search Time. It's used to create an index of terms. To index a phrase, it could be

ElasticSearch & Tire: Using Mapping and to_indexed_json

你说的曾经没有我的故事 提交于 2019-11-28 07:30:56
While reading the Tire doc, I was under the impression that you should use either mapping or to_indexed_json methods, since (my understanding was..) the mapping is used to feed the to_indexed_json . The problem is, that I found some tutorials where both are used. WHY? Basically, my app works right now with the to_indexed_json but I can't figure out how to set the boost value of some of the attributes (hence the reason I started looking at mapping) and I was wondering if using both would create some conflicts. While the mapping and to_indexed_json methods are related, they serve two different

Index the results of a method in ElasticSearch (Tire + ActiveRecord)

蓝咒 提交于 2019-11-28 07:01:32
I'm indexing a data set for elasticsearch using Tire and ActiveRecord. I have an Artist model, which has_many :images. How can I index a method of the Artist model which returns a specific image? Or alternatively reference a method of the associated model? My desired Artist result will include the paths for the primary Image associated with the Artist (both the original and the thumbnail). I've tried this mapping: mapping do indexes :id, :index => :not_analyzed indexes :name indexes :url indexes :primary_image_original indexes :primary_image_thumbnail end to reference these Artist methods: def

Elasticsearch, Tire, and Nested queries / associations with ActiveRecord

北城以北 提交于 2019-11-27 03:18:54
I'm using ElasticSearch with Tire to index and search some ActiveRecord models, and I've been searching for the "right" way to index and search associations. I haven't found what seems like a best practice for this, so I wanted to ask if anyone has an approach that they think works really well. As an example setup (this is made up but illustrates the problem), let's say we have a book, with chapters. Each book has a title and author, and a bunch of chapters. Each chapter has text. We want to index the book's fields and the chapters' text so you can search for a book by author, or for any book