Skip to content

Instantly share code, notes, and snippets.

View spaghetticode's full-sized avatar
🪲
bugs, bugs everywhere

Andrea Longhi spaghetticode

🪲
bugs, bugs everywhere
View GitHub Profile
@spaghetticode
spaghetticode / 05.outputs.md
Last active October 18, 2018 08:39
Outputs

outputs (results+metadata):

-weight-sorted list of matches:

{(ID, weight/relevance, distance)}

By id:

GET /docs/doc/_search 
{
 "query": {
@spaghetticode
spaghetticode / 06.updates.md
Last active October 18, 2018 08:38
06.updates

This second paragraph in total looks very nice. It even shows how to use the "suggest" feature standalone. However, whether or not it may be embedded and executed in the actual search, we do not know. (Note: we're still in operation "2d) search")

You can combine the suggester with a query. You can use the same term or even use different words for suggestion and query. Let's see an example:

GET /docs/doc/_search
{
  "query": {
    "match": {"title": "liitle neemo"}
  },
@spaghetticode
spaghetticode / ElasticSearch_mappings_and_analyzers.json
Last active October 18, 2018 08:38
Beginning Elasticsearch - mappings and analyzers
# Record insertion:
PUT /examples/movies/1
{
"title": "Saving Private Ryan",
"description": "A war movie set during the invasion of Normandy"
}
# see current mappings:
GET /examples/_mapping
# unicorn_rails -c /data/github/current/config/unicorn.rb -E production -D
rails_env = ENV['RAILS_ENV'] || 'production'
# 16 workers and 1 master
worker_processes (rails_env == 'production' ? 16 : 4)
# Load rails+github.git into the master before forking workers
# for super-fast worker spawn times
preload_app true
@spaghetticode
spaghetticode / checkout_insufficient_stock_spec.rb
Created January 4, 2019 08:58
Specs to expose stock validation issues on Solidus checkout confirm page
require 'spec_helper'
describe "Checkout confirm page", type: :feature do
include_context 'checkout setup'
context 'when there is not enough stock at the default stock location' do
context "when the product is not backorderable" do
let(:user) { create(:user) }
let(:order) { Spree::TestingSupport::OrderWalkthrough.up_to(:payment) }
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
gem "rails", github: "rails/rails", branch: "6-0-stable"
gem "sqlite3"
end