Created
October 22, 2015 16:26
-
-
Save loren138/c87774aac650f45de051 to your computer and use it in GitHub Desktop.
Sample Elastic Search Code
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
{"filter":{"bool":{"must":[{"term":{"category":"Speaking and Teaching"}},{"term":{"tags.not_analyzed":"Video"}}],"must_not":[{"term":{"tags.not_analyzed":"Audio"}}]}},"sort":{"date_created":{"order":"desc"}},"size":"10","_source":{"exclude":["transcript","segments.*"]}} |
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
{"_source":"title","query":{"bool":{"must":{"match":{"title.autocomplete":{"query":"Academic Bi","operator":"and"}}},"should":{"multi_match":{"query":"Academic Bi","type":"most_fields","fields":["title^10","title.std","title.shingles"]}}}},"size":"99"} |
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": { | |
"number_of_shards": 1, | |
"number_of_replicas": 2 | |
}, | |
"analysis": { | |
"char_filter" : { | |
"fancy_quotes" : { | |
"type" : "mapping", | |
"mappings" : [ | |
"ι=>'", "’=>'", "“=>\"", "”=>\"", | |
"‘=>'", "’=>'", "“=>\"", "”=>\"", | |
"\\u2018=>'", "\\u2019=>'", "\\u201C=>\"", "\\u201D=>\"", "\\u201F=>\"", | |
"῀=>,", "–=>-", "—=>-", ">=><", "<=>>", | |
"‚=>,", "–=>-", "—=>-", "<=><", ">=>>", | |
"\\u201a=>,", "\\u2013=>-", "\\u2014=>-", "\\u00a0=> ", | |
"&=>and", "&=>and" | |
] | |
} | |
}, | |
"filter": { | |
"my_shingle_filter": { | |
"type": "shingle", | |
"min_shingle_size": 2, | |
"max_shingle_size": 2, | |
"output_unigrams": false | |
}, | |
"autocomplete_filter": { | |
"type": "edge_ngram", | |
"min_gram": 1, | |
"max_gram": 20 | |
}, | |
"english_stop": { | |
"type": "stop", | |
"stopwords": "_english_" | |
}, | |
"english_stemmer": { | |
"type": "stemmer", | |
"language": "english" | |
}, | |
"english_possessive_stemmer": { | |
"type": "stemmer", | |
"language": "possessive_english" | |
} | |
}, | |
"analyzer": { | |
"my_shingle_analyzer": { | |
"type": "custom", | |
"tokenizer": "standard", | |
"char_filter": [ "fancy_quotes", "html_strip" ], | |
"filter": [ | |
"asciifolding", | |
"lowercase", | |
"english_possessive_stemmer", | |
"english_stop", | |
"english_stemmer", | |
"my_shingle_filter" | |
] | |
}, | |
"my_english": { | |
"type": "custom", | |
"tokenizer": "standard", | |
"char_filter": [ "fancy_quotes", "html_strip" ], | |
"filter": [ | |
"asciifolding", | |
"lowercase", | |
"english_possessive_stemmer", | |
"english_stop", | |
"english_stemmer" | |
] | |
}, | |
"my_standard": { | |
"type": "custom", | |
"tokenizer": "standard", | |
"char_filter": [ "fancy_quotes", "html_strip" ], | |
"filter": [ | |
"asciifolding", | |
"lowercase" | |
] | |
}, | |
"autocomplete": { | |
"type": "custom", | |
"tokenizer": "standard", | |
"char_filter": [ "fancy_quotes", "html_strip" ], | |
"filter": [ | |
"lowercase", | |
"asciifolding", | |
"autocomplete_filter" | |
] | |
}, | |
"autocomplete_std": { | |
"type": "custom", | |
"tokenizer": "standard", | |
"char_filter": [ "fancy_quotes", "html_strip" ], | |
"filter": [ | |
"lowercase", | |
"asciifolding" | |
] | |
} | |
} | |
} | |
}, | |
"mappings": { | |
"content": { | |
"properties": { | |
"title": { | |
"type": "string", | |
"index": "analyzed", | |
"analyzer": "my_english", | |
"fields": { | |
"std": { | |
"type": "string", | |
"analyzer": "my_standard" | |
}, | |
"shingles": { | |
"type": "string", | |
"analyzer": "my_shingle_analyzer" | |
}, | |
"autocomplete": { | |
"type": "string", | |
"index_analyzer": "autocomplete", | |
"search_analyzer": "autocomplete_std" | |
} | |
} | |
}, | |
"authors": { | |
"type": "string", | |
"index": "analyzed", | |
"analyzer": "my_standard", | |
"position_offset_gap": 100, | |
"fields": { | |
"not_analyzed": { | |
"type": "string", | |
"index": "not_analyzed" | |
} | |
} | |
}, | |
"date_created": { | |
"type": "date" | |
}, | |
"date_updated": { | |
"type": "date" | |
}, | |
"language": { | |
"type": "string", | |
"index": "not_analyzed" | |
}, | |
"description": { | |
"type": "string", | |
"index": "analyzed", | |
"analyzer": "my_english", | |
"fields": { | |
"std": { | |
"type": "string", | |
"analyzer": "my_standard" | |
}, | |
"shingles": { | |
"type": "string", | |
"analyzer": "my_shingle_analyzer" | |
} | |
} | |
}, | |
"resource": { | |
"type": "object", | |
"properties": { | |
"text": { | |
"type": "object", | |
"properties": { | |
"uri": { | |
"type": "string", | |
"index": "not_analyzed" | |
} | |
} | |
}, | |
"audio": { | |
"type": "object", | |
"properties": { | |
"uri": { | |
"type": "string", | |
"index": "no" | |
}, | |
"duration": { | |
"type": "string", | |
"index": "no" | |
}, | |
"file_size": { | |
"type": "string", | |
"index": "no" | |
}, | |
"type": { | |
"type": "string", | |
"index": "no" | |
} | |
} | |
}, | |
"video": { | |
"type": "object", | |
"properties": { | |
"uri": { | |
"type": "string", | |
"index": "no" | |
}, | |
"duration": { | |
"type": "string", | |
"index": "no" | |
}, | |
"file_size": { | |
"type": "string", | |
"index": "no" | |
}, | |
"type": { | |
"type": "string", | |
"index": "no" | |
}, | |
"vimeo": { | |
"type": "string", | |
"index": "no" | |
}, | |
"youtube": { | |
"type": "string", | |
"index": "no" | |
} | |
} | |
}, | |
"news": { | |
"type": "object", | |
"properties": { | |
"publication": { | |
"type": "string", | |
"index": "no" | |
}, | |
"title": { | |
"type": "string", | |
"index": "no" | |
}, | |
"uri": { | |
"type": "string", | |
"index": "no" | |
} | |
} | |
} | |
} | |
}, | |
"resource_image": { | |
"type": "string", | |
"index": "no" | |
}, | |
"transcript": { | |
"type": "string", | |
"index": "analyzed", | |
"analyzer": "my_english", | |
"fields": { | |
"std": { | |
"type": "string", | |
"analyzer": "my_standard" | |
}, | |
"shingles": { | |
"type": "string", | |
"analyzer": "my_shingle_analyzer" | |
} | |
} | |
}, | |
"category": { | |
"type": "string", | |
"index": "not_analyzed" | |
}, | |
"scripture": { | |
"type": "string", | |
"index": "analyzed", | |
"analyzer": "my_standard", | |
"position_offset_gap": 100, | |
"fields": { | |
"not_analyzed": { | |
"type": "string", | |
"index": "not_analyzed" | |
} | |
} | |
}, | |
"tags": { | |
"type": "string", | |
"index": "analyzed", | |
"analyzer": "my_standard", | |
"position_offset_gap": 100, | |
"fields": { | |
"not_analyzed": { | |
"type": "string", | |
"index": "not_analyzed" | |
} | |
} | |
}, | |
"segments": { | |
"type": "nested", | |
"index": "no", | |
"properties": { | |
"title": { | |
"type": "string", | |
"index": "no" | |
}, | |
"description": { | |
"type": "string", | |
"index": "no" | |
}, | |
"transcript": { | |
"type": "string", | |
"index": "no" | |
}, | |
"startTime": { | |
"type": "integer", | |
"index": "no" | |
}, | |
"stopTime": { | |
"type": "integer", | |
"index": "no" | |
}, | |
"citations": { | |
"type": "nested", | |
"index": "no", | |
"properties": { | |
"publication": { | |
"type": "string", | |
"index": "no" | |
}, | |
"title": { | |
"type": "string", | |
"index": "no" | |
}, | |
"uri": { | |
"type": "string", | |
"index": "no" | |
} | |
} | |
} | |
} | |
}, | |
"origin_id": { | |
"type": "string", | |
"index": "no" | |
} | |
} | |
}, | |
"news": { | |
"properties": { | |
"title": { | |
"type": "string", | |
"index": "analyzed", | |
"analyzer": "my_english", | |
"fields": { | |
"std": { | |
"type": "string", | |
"analyzer": "my_standard" | |
}, | |
"shingles": { | |
"type": "string", | |
"analyzer": "my_shingle_analyzer" | |
}, | |
"autocomplete": { | |
"type": "string", | |
"index_analyzer": "autocomplete", | |
"search_analyzer": "autocomplete_std" | |
} | |
} | |
}, | |
"authors": { | |
"type": "string", | |
"index": "analyzed", | |
"analyzer": "my_standard", | |
"position_offset_gap": 100, | |
"fields": { | |
"not_analyzed": { | |
"type": "string", | |
"index": "not_analyzed" | |
} | |
} | |
}, | |
"date_created": { | |
"type": "date" | |
}, | |
"date_updated": { | |
"type": "date" | |
}, | |
"language": { | |
"type": "string", | |
"index": "not_analyzed" | |
}, | |
"description": { | |
"type": "string", | |
"index": "analyzed", | |
"analyzer": "my_english", | |
"fields": { | |
"std": { | |
"type": "string", | |
"analyzer": "my_standard" | |
}, | |
"shingles": { | |
"type": "string", | |
"analyzer": "my_shingle_analyzer" | |
} | |
} | |
}, | |
"resource": { | |
"type": "object", | |
"properties": { | |
"text": { | |
"type": "object", | |
"properties": { | |
"uri": { | |
"type": "string", | |
"index": "not_analyzed" | |
} | |
} | |
}, | |
"audio": { | |
"type": "object", | |
"properties": { | |
"uri": { | |
"type": "string", | |
"index": "no" | |
}, | |
"duration": { | |
"type": "string", | |
"index": "no" | |
}, | |
"file_size": { | |
"type": "string", | |
"index": "no" | |
}, | |
"type": { | |
"type": "string", | |
"index": "no" | |
} | |
} | |
}, | |
"video": { | |
"type": "object", | |
"properties": { | |
"uri": { | |
"type": "string", | |
"index": "no" | |
}, | |
"duration": { | |
"type": "string", | |
"index": "no" | |
}, | |
"file_size": { | |
"type": "string", | |
"index": "no" | |
}, | |
"type": { | |
"type": "string", | |
"index": "no" | |
}, | |
"vimeo": { | |
"type": "string", | |
"index": "no" | |
}, | |
"youtube": { | |
"type": "string", | |
"index": "no" | |
} | |
} | |
}, | |
"news": { | |
"type": "object", | |
"properties": { | |
"publication": { | |
"type": "string", | |
"index": "no" | |
}, | |
"title": { | |
"type": "string", | |
"index": "no" | |
}, | |
"uri": { | |
"type": "string", | |
"index": "no" | |
} | |
} | |
} | |
} | |
}, | |
"resource_image": { | |
"type": "string", | |
"index": "no" | |
}, | |
"transcript": { | |
"type": "string", | |
"index": "analyzed", | |
"analyzer": "my_english", | |
"fields": { | |
"std": { | |
"type": "string", | |
"analyzer": "my_standard" | |
}, | |
"shingles": { | |
"type": "string", | |
"analyzer": "my_shingle_analyzer" | |
} | |
} | |
}, | |
"category": { | |
"type": "string", | |
"index": "not_analyzed" | |
}, | |
"scripture": { | |
"type": "string", | |
"index": "analyzed", | |
"analyzer": "my_standard", | |
"position_offset_gap": 100, | |
"fields": { | |
"not_analyzed": { | |
"type": "string", | |
"index": "not_analyzed" | |
} | |
} | |
}, | |
"tags": { | |
"type": "string", | |
"index": "analyzed", | |
"analyzer": "my_standard", | |
"position_offset_gap": 100, | |
"fields": { | |
"not_analyzed": { | |
"type": "string", | |
"index": "not_analyzed" | |
} | |
} | |
}, | |
"segments": { | |
"type": "nested", | |
"index": "no", | |
"properties": { | |
"title": { | |
"type": "string", | |
"index": "no" | |
}, | |
"description": { | |
"type": "string", | |
"index": "no" | |
}, | |
"transcript": { | |
"type": "string", | |
"index": "no" | |
}, | |
"startTime": { | |
"type": "integer", | |
"index": "no" | |
}, | |
"stopTime": { | |
"type": "integer", | |
"index": "no" | |
}, | |
"citations": { | |
"type": "nested", | |
"index": "no", | |
"properties": { | |
"publication": { | |
"type": "string", | |
"index": "no" | |
}, | |
"title": { | |
"type": "string", | |
"index": "no" | |
}, | |
"uri": { | |
"type": "string", | |
"index": "no" | |
} | |
} | |
} | |
} | |
}, | |
"origin_id": { | |
"type": "string", | |
"index": "no" | |
} | |
} | |
} | |
} | |
} |
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
{"query":{"function_score":{"query":{"multi_match":{"query":"yoga","type":"most_fields","fields":["title^10","title.std","title.shingles","authors^10","language^10","description^10","description.std","description.shingles","transcript^10","transcript.std","transcript.shingles","scripture^10","tags^10","origin_id^10"]}},"functions":[{"gauss":{"date_created":{"origin":"now\/d","scale":"50w","offset":"4w","decay":"0.5"}}}]}},"_source":{"exclude":["transcript","segments.*"]},"size":"10"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment