Example: where (place.type = 'Restaurant' and place.kind = 'Chinese') or (place.type = 'Bar' and place.kind in ('beer','wine'))
{
query: {
bool: {
should: [
{
bool: {
| class EncryptionEngine | |
| def self.encrypt(string) | |
| results = '' | |
| string.each_char do |l| | |
| results += rot(l) | |
| end | |
| results | |
| end | |
| def self.decrypt(string) |
| class BeerSong | |
| def verse(nb_bottle) | |
| s = "#{pluralize(nb_bottle, capitalize: true)} of beer on the wall, #{pluralize(nb_bottle)} of beer.\n" | |
| s + if nb_bottle == 0 | |
| "Go to the store and buy some more, 99 bottles of beer on the wall.\n" | |
| else | |
| "Take #{it_or_one(nb_bottle - 1)} down and pass it around, #{pluralize(nb_bottle - 1)} of beer on the wall.\n" | |
| end | |
| end |
| # See link below to know all possible filters | |
| # https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl.html | |
| class UserSearch | |
| def initialize(user, string_query) | |
| @user = user | |
| @string_query = string_query | |
| end | |
| def search |
| // https://medium.com/freenet-engineering/memory-leaks-in-android-identify-treat-and-avoid-d0b1233acc8 |
| # app/controllers/admin | |
| class Admin::PostController < ActionController::Base | |
| before_action :authenticate_admin! | |
| def index | |
| @posts = Post.all | |
| end | |
| def switch_user |
| class MyClass | |
| def self.public | |
| "I'm public." | |
| end | |
| private # this is useless | |
| def self.private | |
| "I'm also public." | |
| end |
| require 'sudoku' | |
| require 'sudoku_solver' | |
| data = [ | |
| [9, 3, 4, 1, 7, 2, 6, 8, 5], | |
| [0, 0, 5, 0, 9, 0, 2, 0, 1], | |
| [8, 0, 0, 0, 4, 0, 0, 0, 0], | |
| [0, 0, 0, 0, 8, 0, 0, 0, 0], | |
| [0, 0, 0, 7, 0, 0, 0, 0, 0], | |
| [0, 0, 0, 0, 2, 6, 0, 0, 9], |
| { | |
| "detect_indentation": false, | |
| "draw_white_space": "all", | |
| "ensure_newline_at_eof_on_save": true, | |
| "folder_exclude_patterns": | |
| [ | |
| ".svn", | |
| ".git", | |
| ".hg", | |
| "CVS", |