Skip to content

Instantly share code, notes, and snippets.

@byronvoorbach
Last active June 27, 2017 13:11
Show Gist options
  • Save byronvoorbach/e84c5623d58d4acabf4ee2ae4b9924e7 to your computer and use it in GitHub Desktop.
Save byronvoorbach/e84c5623d58d4acabf4ee2ae4b9924e7 to your computer and use it in GitHub Desktop.
PUT webshop
{
"settings": {
"number_of_shards": 1,
"number_of_replicas": 0,
"analysis": {
"filter": {
},
"analyzer": {
}
}
},
"mappings": {
"shop" : {
"properties": {
}
}
}
}
POST webshop/shop/1
{
"title": "Game of Thrones - Season 3 Blu-Ray Disc",
"release_date": 646437600000
}
POST webshop/shop/2
{
"title": "Canon EOS500-D 12.1MP Camera",
"release_date": 646437600000
}
POST webshop/shop/3
{
"title": "Hello Kitty - Armband",
"release_date": 1498514400000
}
POST webshop/shop/4
{
"title": "Wijnglazen - Rood - 4 stuks",
"release_date": 1498514400000
}
GET webshop/shop/_search
{
"query": {
"match": {
"title": {
"query": "Game of Throne",
"operator": "and"
}
}
}
}
GET webshop/shop/_search
{
"query": {
"match": {
"title": {
"query": "GOT",
"operator": "and"
}
}
}
}
GET webshop/shop/_search
{
"query": {
"match": {
"title": {
"query": "Canon 500",
"operator": "and"
}
}
}
}
GET webshop/shop/_search
{
"query": {
"range": {
"release_date": {
"gte": "now-7d"
}
}
}
}
GET webshop/shop/_search
{
"query": {
"match": {
"title": {
"query": "Wijnglaasjes"
}
}
}
}
##### ANSWER (One of the possibilities) #####
DELETE webshop
PUT webshop
{
"settings": {
"number_of_shards": 1,
"number_of_replicas": 0,
"analysis": {
"filter": {
"synonym": {
"type": "synonym",
"synonyms": [
"got=>game of thrones",
"wijnglaasjes=>wijnglazen"
]
},
"stemming": {
"type": "stemmer",
"name": "dutch_kp"
},
"delimiter": {
"type": "word_delimiter",
"split_on_numerics" : true
}
},
"analyzer": {
"title_analyzer": {
"tokenizer": "standard",
"filter": [
"asciifolding",
"lowercase",
"delimiter",
"synonym",
"stemming"
]
}
}
}
},
"mappings": {
"shop": {
"properties": {
"title" : {
"type": "text",
"analyzer": "title_analyzer"
},
"release_date" : {
"type": "date"
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment