This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*.gem | |
*.rbc | |
.bundle | |
.config | |
.yardoc | |
usage.rb | |
Gemfile.lock | |
InstalledFiles | |
_yardoc | |
coverage |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$:.push File.expand_path("../lib", __FILE__) | |
Gem::Specification.new do |s| | |
s.name = 'meta_information' | |
s.version = '1.0.1' | |
s.date = '2017-02-26' | |
s.summary = 'MetaInformation - Simple gem for parsing meta information' | |
s.description = 'Simple gem for parsing meta information from websites. It scan all meta-tags by name or property attributes.' | |
s.author = 'Vladislav Kopylov' | |
s.email = '[email protected]' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module EsHelper | |
def as_indexed_json(params={}) | |
{ | |
title: title, | |
description: description, | |
searching: searching | |
} | |
end | |
def preview |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ElasticMyAnalyzer | |
ES_SETTING = { | |
index: { | |
number_of_shards: 1 | |
}, | |
analysis: { | |
filter: { | |
my_stopwords: { | |
type: 'stop', | |
stopwords: 'а,без,более,бы,был,была,были,было,быть,в,вам,вас,весь,во,вот,все,всего,всех,вы,где,да,даже,для,до,его,ее,если,есть,еще,же,за,здесь,и,из,или,им,их,к,как,ко,когда,кто,ли,либо,мне,может,мы,на,надо,наш,не,него,нее,нет,ни,них,но,ну,о,об,однако,он,она,они,оно,от,очень,по,под,при,с,со,так,также,такой,там,те,тем,то,того,тоже,той,только,том,ты,у,уже,хотя,чего,чей,чем,что,чтобы,чье,чья,эта,эти,это,я' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Article < ActiveRecord::Base | |
include Elasticsearch::Model | |
include Elasticsearch::Model::Callbacks | |
include ElasticMyAnalyzer | |
include EsHelper | |
settings ES_SETTING do | |
mappings dynamic: 'true' do | |
indexes :title, type: 'string', analyzer: 'my_analyzer' # or type: 'text' for version 6.1 | |
indexes :description, type: 'string', analyzer: 'my_analyzer' # or type: 'text' for version 6.1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MultySearch | |
MODELS_TO_SEARCH = [Article, BlogPost, News].freeze | |
def initialize | |
@raw_data = nil | |
@results = nil | |
end | |
def search(search_word, page = nil, per_page = nil) | |
page ||= 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Article.create!( | |
title: 'Шерлок Холмс цитата 1', | |
description: 'Человек, который любит искусство ради искусства, самое большое удовольствие зачастую черпает из наименее значительных и ярких его проявлений.', | |
searching: true | |
) | |
Article.create!( | |
title: 'Шерлок Холмс цитата 2', | |
description: 'Самая смелая фантазия не в силах представить себе тех необычайных и диковинных случаев, какие встречаются в обыденной жизни.', | |
searching: true | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
= form_tag '/search', method: 'GET' do | |
= text_field_tag :query, params[:query] | |
= submit_tag 'Искать' | |
- if @searching.present? | |
.search_resulting | |
p | |
| Были найдены следующие результаты | |
- @searching.results.each do |result| | |
.search_result |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
u = User.new(email: '[email protected]') | |
u.password = u.email | |
u.save | |
child_1 = Kid.create!(name: 'kid 1', desc: 'has_camp', user_id: u.id) | |
child_2 = Kid.create!(name: 'kid 2', desc: 'has_camp', user_id: u.id) | |
child_3 = Kid.create!(name: 'kid 3', desc: 'without camp', user_id: u.id) | |
camp = Camp.create!(name: 'first_camp', desc: 'none') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// object | |
let obj = { | |
foo: 'bar' | |
} | |
let bazStr = 'baz' | |
obj[bazStr] = (x, y) => { | |
return x + y | |
} | |
console.log(obj.baz(2, 3)) // 5 | |
console.log('----------') |