This file contains 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
require 'action_dispatch/routing/route_set' | |
# Based on https://gist.github.com/2830082 | |
module ActionDispatch | |
module Routing | |
class RouteSet | |
class Dispatcher | |
def call_with_invalid_char_handling(env) | |
uri = CGI::unescape(env["REQUEST_URI"].force_encoding("UTF-8")) | |
# If anything in the REQUEST_URI has an invalid encoding, then raise since it's likely to trigger errors further on. | |
return [400, {'X-Cascade' => 'pass'}, []] if uri.is_a?(String) and !uri.valid_encoding? |
This file contains 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
{ | |
"development-asis-flickr_photos": { | |
"mappings": { | |
"flickr_photo": { | |
"properties": { | |
"description": { | |
"type": "string", | |
"analyzer": "en_analyzer" | |
}, | |
"owner": { |
This file contains 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
{ | |
"development-asis-instagram_photos": { | |
"mappings": { | |
"instagram_photo": { | |
"properties": { | |
"caption": { | |
"type": "string", | |
"analyzer": "en_analyzer" | |
}, | |
"popularity": { |
This file contains 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
{ | |
"settings": { | |
"index": { | |
"analysis": { | |
"char_filter": { | |
"ignore_chars": { | |
"type": "mapping", | |
"mappings": [ | |
"'=>", | |
"\u2019=>", |
This file contains 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
GET http://localhost:9200/development-asis-flickr_photos,development-asis-instagram_photos/_search | |
{ | |
"query": { | |
"function_score": { | |
"functions": [ | |
{ | |
"field_value_factor": { | |
"field": "popularity", | |
"modifier": "log2p" | |
} |
This file contains 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
{ | |
"functions": [ | |
{ | |
"field_value_factor": { | |
"field": "popularity", | |
"modifier": "log2p" | |
} | |
}, | |
{ | |
"filter": { |
This file contains 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
{ | |
"bool": { | |
"should": [ | |
{ | |
"match": { | |
"tags": { | |
"query": "jefferson memorial", | |
"analyzer": "tag_analyzer" | |
} | |
} |
This file contains 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
{ | |
"properties": { | |
"bigram": { | |
"type": "string", | |
"analyzer": "bigram_analyzer" | |
}, | |
"description": { | |
"type": "string", | |
"analyzer": "en_analyzer", | |
"copy_to": [ |
This file contains 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
{ | |
"properties": { | |
"bigram": { | |
"type": "string", | |
"analyzer": "bigram_analyzer" | |
}, | |
"caption": { | |
"type": "string", | |
"analyzer": "en_analyzer", | |
"copy_to": [ |
This file contains 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
{ | |
"suggest": { | |
"text": "jeferson memorial", | |
"suggestion": { | |
"phrase": { | |
"analyzer": "bigram_analyzer", | |
"field": "bigram", | |
"size": 1, | |
"direct_generator": [ | |
{ |
OlderNewer