Skip to content

Instantly share code, notes, and snippets.

@pierresetteskog
Last active August 29, 2015 14:18
Show Gist options
  • Save pierresetteskog/5d8bf08222307e5249ca to your computer and use it in GitHub Desktop.
Save pierresetteskog/5d8bf08222307e5249ca to your computer and use it in GitHub Desktop.
DELETE issues
POST issues
{
"mappings": {
"_default_": {
"dynamic_date_formats": [
"yyyy-MM-dd",
"dd-MM-yyyy",
"date_optional_time"
],
"_timestamp": {
"enabled": true,
"store": true
},
"search_analyzer": "default_search",
"index_analyzer": "default_index",
"dynamic_templates": [
{
"string_as_analyzed_nongram": {
"mapping": {
"include_in_all": false,
"analyzer": "default_search",
"index": "analyzed",
"type": "string"
},
"match_mapping_type": "string",
"match": "analyzed_nongram_*"
}
},
{
"string_as_analyzed": {
"mapping": {
"index": "analyzed",
"type": "string"
},
"match_mapping_type": "string",
"match": "analyzed_*"
}
},
{
"string_as_not_analyzed": {
"mapping": {
"index": "not_analyzed",
"type": "string"
},
"match_mapping_type": "string",
"match": "notanalyzed_*"
}
},
{
"string_as_not_enabled": {
"mapping": {
"include_in_all": false,
"type": "string",
"enabled": "false"
},
"match_mapping_type": "string",
"match": "notenabled_*"
}
},
{
"disp_as_not_analyzed": {
"mapping": {
"index": "not_analyzed",
"type": "string"
},
"match_mapping_type": "string",
"match": "disp_*"
}
},
{
"attr_as_not_analyzed": {
"mapping": {
"index": "not_analyzed",
"type": "string"
},
"match_mapping_type": "string",
"match": "attr_*"
}
},
{
"multi_as_multivalue": {
"mapping": {
"path": "just_name",
"type": "multi_field",
"fields": {
"analyzed_nongram_{name}": {
"analyzer": "default_search",
"index": "analyzed",
"type": "string"
},
"{name}": {
"index": "not_analyzed",
"type": "string"
},
"analyzed_{name}": {
"index": "analyzed",
"type": "string"
}
}
},
"match_mapping_type": "string",
"match": "multi_*,Name,Description,Suggestions"
}
},
{
"string_as_multivalue": {
"mapping": {
"path": "just_name",
"type": "multi_field",
"fields": {
"analyzed_nongram_{name}": {
"analyzer": "default_search",
"index": "analyzed",
"type": "string"
},
"{name}": {
"index": "not_analyzed",
"type": "string"
},
"analyzed_{name}": {
"index": "analyzed",
"type": "string"
}
}
},
"match_mapping_type": "string",
"match": "*"
}
}
],
"properties": {}
}
},
"settings": {
"index": {
"number_of_shards": 1,
"number_of_replicas": 0,
"analysis": {
"filter": {
"synonym": {
"type": "synonym",
"synonyms": [
"SYNONYMS"
]
},
"ngram": {
"type": "nGram",
"min_gram": "1",
"max_gram": "30",
"token_chars": [
"letter",
"digit",
"punctuation",
"symbol"
]
},
"ascii_folding": {
"type": "asciifolding",
"preserve_original": true
}
},
"analyzer": {
"default_search": {
"type": "custom",
"filter": [
"lowercase",
"ascii_folding"
],
"tokenizer": "standard"
},
"default_index": {
"type": "custom",
"filter": [
"lowercase",
"synonym",
"ascii_folding",
"ngram"
],
"tokenizer": "standard",
"char_filter": "html_strip"
}
}
}
}
}
}
POST issues/Issue/no1
{
"ID": "no1",
"Name": "Gillar hamburgare för mycket",
"Desciption": "Ipsum lorum.....",
"Status": "Open",
"Category": "mat uplevelse",
"Region": "Göteborg",
"CreatedDate": "2010-01-01T14:12:12",
"ModifiedDate" :"2010-01-01",
"Priority": 1,
"Solution": "",
"Readers": ["Sysadmin","regionwest"]
}
POST issues/Issue/no2
{
"ID": "no2",
"Name": "Gillar inte lokalen",
"Desciption": "Ipsum lorum.....",
"Status": "Closed",
"Category": "lokal",
"Region": "Stockholm",
"CreatedDate": "2010-01-01T14:12:12",
"ModifiedDate" :"2010-02-01",
"Priority": 1,
"Solution": "I fix",
"Readers": ["Sysadmin"]
}
POST issues/Issue/no3?refresh=true
{
"ID": "no3",
"Name": "Gillar inte lokalen 2",
"Desciption": "Ipsum lorum.....",
"Status": "Open",
"Category": "lokal",
"Region": "Stockholm",
"CreatedDate": "2010-01-01T14:12:12",
"ModifiedDate" :"2010-03-01",
"Priority": 1,
"Solution": "",
"Readers": ["Sysadmin"]
}
POST issues/Issue/_search
{
"from": 0,
"size": 10,
"query": {
"function_score": {
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"bool": {
"must": [
{
"terms": {
"Status": [
"Open"
]
}
},
{
"terms": {
"Readers": [
"Sysadmin"
]
}
}
]
}
}
}
},
"functions": [
{
"script_score": {
"script": "_score * doc['Priority'].value"
}
}
]
}
},
"post_filter": {
"bool": {
"must": []
}
},
"aggs": {
"Region": {
"terms": {
"field": "Region",
"order": {
"_term": "asc"
},
"size": 10000
}
},
"Status": {
"terms": {
"field": "Status",
"order": {
"_term": "asc"
},
"size": 10000
}
},
"Category": {
"terms": {
"field": "Category",
"order": {
"_term": "asc"
},
"size": 10000
}
}
},
"sort": [
{
"Name": {
"order": "asc",
"ignore_unmapped": true,
"mode": "min",
"missing": "_last"
}
},
"_score"
]
}
POST issues/Issue/_search
{
"from": 0,
"size": 10,
"query": {
"function_score": {
"query": {
"filtered": {
"query": {
"simple_query_string": {
"fields": [
"_all^1",
"analyzed_Category^2",
"analyzed_Name^30"
],
"query": "hamburgar~2",
"default_operator": "and",
"flags": "FUZZY"
}
},
"filter": {
"bool": {
"must": [
{
"terms": {
"Status": [
"Open"
]
}
},
{
"terms": {
"Readers": [
"Sysadmin"
]
}
}
]
}
}
}
},
"field_value_factor": {"field": "Priority"}
}
},
"aggs": {
"Region": {
"terms": {
"field": "Region",
"order": {
"_term": "asc"
},
"size": 10000
}
},
"Status": {
"terms": {
"field": "Status",
"order": {
"_term": "asc"
},
"size": 10000
}
},
"Category": {
"terms": {
"field": "Category",
"order": {
"_term": "asc"
},
"size": 10000
}
}
},
"sort": [
{
"Name": {
"order": "asc",
"ignore_unmapped": true,
"mode": "min",
"missing": "_last"
}
},
"_score"
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment