Skip to content

Instantly share code, notes, and snippets.

@MohammedJabarullah
Last active December 15, 2015 10:09
Show Gist options
  • Save MohammedJabarullah/5243554 to your computer and use it in GitHub Desktop.
Save MohammedJabarullah/5243554 to your computer and use it in GitHub Desktop.
{
"settings" : {
"analysis" : {
"analyzer" : {
"default" : {
"tokenizer" : "whitespace",
"filter" : [ "thesaurus_synonyms", "lowercase", "snow_en" ]
},
"make_analyzer" : {
"tokenizer" : "whitespace",
"filter" : [ "make_synonyms" ]
}
},
"filter" : {
"snow_en" : {
"type" : "snowball",
"language" : "English"
},
"thesaurus_synonyms" : {
"type" : "synonym",
"synonyms" : [
"3-SERIES, 3SERIES => 3 SERIES",
"TOYATO, TOYTA => TOYOTA"
]
},
"make_synonyms" : {
"type" : "synonym",
"synonyms" : [
"Bayerische Motoren Werke, B.M.W => BMW"
]
}
}
}
}
}
#!/bin/bash
echo "Delete all indices under tenant demo"
curl -XDELETE 'http://localhost:9200/demo'; echo
echo "Create tenant demo"
#curl -XPUT 'http://localhost:9200/demo/' -d @demo_index.json; echo
curl -XPUT 'http://localhost:9200/demo/'; echo
echo "Create vehicle index"
curl -XPUT 'http://localhost:9200/demo/vehicle/_mapping' -d @demo_vehicle_mapping.json; echo
curl -s -XPOST 'localhost:9200/_bulk' --data-binary @demo_vehicles.json; echo
echo Refresh the index
curl -XPOST 'http://localhost:9200/demo/_refresh?pretty=true'; echo
echo "Get the index status"
curl -XGET 'http://localhost:9200/demo/_count?pretty=true'; echo
curl -XGET 'http://localhost:9200/demo/vehicle/_search?pretty=true' -d '
{
"query": {
"match_all": {}
},
"sort": [
{
"year": "desc",
"make": "asc"
}
],
"from": 0,
"size": 3
}
'; echo
echo "Get Trims"
curl -XGET 'http://localhost:9200/demo/vehicle/_search?pretty=true' -d '
{
"size": 0,
"query": {
"filtered": {
"query": {
"terms": {
"make": [
"Honda",
"Audi"
],
"model": [
"Accord",
"R8"
]
}
}
}
},
"facets": {
"trims": {
"terms": {
"field": "trim"
}
}
}
}
'; echo
{
"vehicle" : {
"_source" : {
"enabled" : true
},
"_timestamp" : {
"enabled" : true
},
"_all" : {
"enabled" : true
},
"date_detection" : false,
"numeric_detection" : true,
"properties" : {
"make" : {
"type" : "string",
"index" : "not_analyzed"
},
"model" : {
"type" : "string",
"index" : "not_analyzed"
},
"trim" : {
"type" : "string",
"index" : "not_analyzed"
},
"year" : {
"type" : "integer",
"index" : "not_analyzed"
},
"location" : {
"index" : "not_analyzed",
"type" : "geo_point"
}
}
}
}
{"index":{"_index":"demo","_type":"vehicle","_id":"vehicle_1"}}
{"make": "Honda", "model": "Accord", "trim": "EX-L V6", "year": 2009, "location": "33.45,84.23"}
{"index":{"_index":"demo","_type":"vehicle","_id":"vehicle_2"}}
{"make": "Honda", "model": "Civic", "trim": "EX", "year": 2013, "location": "a"}
{"index":{"_index":"demo","_type":"vehicle","_id":"vehicle_3"}}
{"make": "Acura", "model": "Integra", "trim": "EX", "year": 2008, "location": "38.53,77.02"}
{"index":{"_index":"demo","_type":"vehicle","_id":"vehicle_4"}}
{"make": "AUDI", "model": "R8", "trim": "V10", "year": 2005, "location": "33.45,84.23"}
{"index":{"_index":"demo","_type":"vehicle","_id":"vehicle_5"}}
{"make": "Toyota", "model": "Corolla", "trim": "EX-L", "latitudeLongitude": "9.91,78.11"}
{"index":{"_index":"demo","_type":"vehicle","_id":"vehicle_6"}}
{"make": "TOYTA", "model": "Tacoma", "trim": "Double Cab", "year": 2005, "location": "33.45,84.23"}
{"index":{"_index":"demo","_type":"vehicle","_id":"vehicle_7"}}
{"make": "TOYATO", "model": "Tacoma", "trim": "Regular Cab", "year": 2005, "location": "9.91,78.11"}
{"index":{"_index":"demo","_type":"vehicle","_id":"vehicle_8"}}
{"make": "TOYOTA", "model": "Avalon", "trim": "XLE", "year": 2003, "location": "38.53,77.02"}
{"index":{"_index":"demo","_type":"vehicle","_id":"vehicle_9"}}
{"make": "Toyota", "model": "Camry", "trim": "EX-L", "latitudeLongitude": "33.45,84.23"}
{"index":{"_index":"demo","_type":"vehicle","_id":"vehicle_10"}}
{"make": "Nissan", "model": "Altima", "trim": "EX", "latitudeLongitude": "9.91,78.11"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment