Skip to content

Instantly share code, notes, and snippets.

@zumo64
Created September 26, 2016 12:32
Show Gist options
  • Save zumo64/f58354186fb7a695101dd183968f4907 to your computer and use it in GitHub Desktop.
Save zumo64/f58354186fb7a695101dd183968f4907 to your computer and use it in GitHub Desktop.
search workshop
GET _cat/health
GET _cat/indices
GET /_cat/plugins
DELETE melimemo
PUT melimemo
{
"index.mapper.dynamic":false,
"mappings": {
"user": {
"properties": {
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
},
"facebook": {
"type": "string",
"index": "not_analyzed"
},
"username": {
"type": "string",
"index": "not_analyzed"
},
"password": {
"type": "string",
"index": "not_analyzed"
},
"pseudo": {
"type": "string",
"index": "not_analyzed"
},
"description": {
"type": "string"
},
"blacklisted": {
"type": "boolean"
},
"dateOfBirth": {
"type": "date"
}
}
},
"memos": {
"_parent": {
"type": "user"
},
"properties": {
"memoTypes": {
"type": "string"
},
"keywords": {
"type": "string"
},
"textMemo": {
"type": "string"
},
"city": {
"type": "string",
"index": "not_analyzed"
},
"country": {
"type": "string",
"index": "not_analyzed"
},
"memoMood": {
"type": "byte"
},
"memoState": {
"type": "byte"
},
"memoSecure": {
"type": "byte"
},
"memoPassword": {
"type": "string",
"index": "not_analyzed"
},
"urlTrack": {
"type": "string",
"index": "not_analyzed"
},
"timesRead": {
"type": "integer"
},
"memoLocation": {
"type": "geo_point"
},
"ratings": {
"type": "byte"
},
"popularityScore": {
"type": "integer"
},
"ratingScore": {
"type": "float"
},
"title": {
"type": "string"
},
"memoLang": {
"type": "string",
"index": "not_analyzed"
},
"photos": {
"properties": {
"id": {
"type": "string",
"index": "not_analyzed"
},
"url": {
"type": "string",
"index": "not_analyzed"
}
}
},
"dateCreated": {
"type": "date"
},
"dateUpdated": {
"type": "date"
},
"dateEvent": {
"type": "date"
},
"memoLocationApprox": {
"type": "byte"
},
"memoDateApprox": {
"type": "integer"
}
}
}
}
}
GET /_template
DELETE /apachelogs-*
DELETE _template/accident_template
GET /_aliases
GET /alias1/type1/2
GET _cat/indices
DELETE /accidentology
PUT /accidentology/type1/2
{
"salope":"grosse pute"
}
PUT /_template/accident_template
{
"template": "accidentology",
"settings": {
"index.number_of_shards": 1,
"index.number_of_replicas": 0
},
"mappings": {
"accident": {
"dynamic_templates": [
{
"string_fields": {
"mapping": {
"index": "not_analyzed",
"omit_norms": true,
"type": "string"
},
"match_mapping_type": "string",
"match": "*"
}
}
],
"_all": {
"enabled": false
},
"properties": {
"location": {
"type": "geo_point"
},
"involvedCount": {
"type": "double"
},
"dayLight": {
"type": "integer",
"fields": {
"raw": {
"type": "string",
"index": "not_analyzed"
}
}
},
"rain": {
"type": "float",
"fields": {
"raw": {
"type": "string",
"index": "not_analyzed"
}
}
},
"tempMin": {
"type": "float",
"fields": {
"raw": {
"type": "string",
"index": "not_analyzed"
}
}
},
"tempMax": {
"type": "float",
"fields": {
"raw": {
"type": "string",
"index": "not_analyzed"
}
}
},
"Address1": {
"type": "string",
"fields": {
"raw": {
"type": "string",
"index": "not_analyzed"
},
"untouched": {
"type": "string",
"index": "analyzed"
}
}
}
}
}
},
"aliases" : {
"alias1": {}
}
}
# Start
PUT _template/my_data_template1
{
"template": "my_data_*",
"settings": {
"number_of_shards": 1
},
"mappings": {
"_default_": {
"_all": {
"enabled": false
}
}
},
"order": 10
}
PUT _template/my_data_template2
{
"template": "my_data_1*",
"mappings": {
"_default_": {
"_all": {
"enabled": false
},
"dynamic": "strict",
"properties":{
"name":{
"type":"text"
},
"country":{
"type":"text"
},
"age":{
"type":"long"
}
}
}
},
"order": 11
}
PUT /my_data_12/type/1
{
"name":"John",
"country":"Denmark",
"age" : 23
}
GET _cat/indices/my_data*
GET /my_data_12/type/1
PUT /my_data_12/type/2
{
"name":"John",
"country":"Denmark",
"age" : 23,
"role":"master"
}
# Cleanup
DELETE my_data_12
DELETE _template/my_data_template*
GET /_nodes/stats
GET /melimemo/_stats
POST /melimemo/user/_search
{
"size": 50,
"query": {
"match_all": {}
}
}
POST /melimemo/user/_search
{
"query": {
"bool": {
"must": [
{"match": {
"password": "6e0b4ca56644020d7c130fbb9aaa0de6"
}}
]
}
}
}
PUT /melimemo/_settings
{
"index.merge.scheduler.max_thread_count":1
}
PUT /test/type/1
{
"name":"zumo",
"age":51
}
PUT /test/type/2
{
"name":"paco",
"age":56
}
PUT /test/type/4
{
"name":"paco de lucia",
"age":56
}
PUT /test/type/3
{
"name":"zulu",
"age":34
}
# score = 1 : There is scoring un query context
GET /test/type/_search
{
"query": {
"term": {
"age": {
"value": 34
}
}
}
}
# score = 0 : There is NO scoring
GET /test/type/_search
{
"query": {
"constant_score": {
"filter": {
"bool": {
"should": [
{
"term": {
"age": {
"value": 34
}
}
},
{
"term": {
"name": {
"value": "zule"
}
}
}
]
}
}
}
}
}
GET /test/type/_search
{
"query": {
"bool": {
"filter": {
"bool": {
"should": [
{
"term": {
"age": {
"value": 34
}
}
},
{
"term": {
"name": {
"value": "zule"
}
}
}
]
}
}
}
}
}
GET /test/type/_search
{
"query": {
"bool": {
"must": [
{"match": {
"name": "TEXT"
}}
]
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment