Last active
July 2, 2016 19:20
-
-
Save enjalot/a8fb0e18c960a37d1d18 to your computer and use it in GitHub Desktop.
elasticsearch mappings for blockbuilder-search-index
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
DELETE /blockbuilder | |
PUT /blockbuilder | |
{ | |
"mappings": { | |
"blocks": { | |
"properties": { | |
"userId": { | |
"type": "string", | |
"index": "not_analyzed" | |
}, | |
"created_at": { | |
"type": "date" | |
}, | |
"updated_at": { | |
"type": "date" | |
}, | |
"api": { | |
"type": "string", | |
"index": "not_analyzed" | |
}, | |
"colors": { | |
"type": "string", | |
"index": "not_analyzed" | |
}, | |
"filenames": { | |
"type": "string", | |
"index": "not_analyzed" | |
}, | |
"d3version": { | |
"type": "string", | |
"index": "not_analyzed" | |
}, | |
"d3modules": { | |
"type": "string", | |
"index": "not_analyzed" | |
} | |
} | |
} | |
} | |
} | |
# the d3version can be v2, v3, v4, IDK, NA | |
PUT /blockbuilder/_mappings/blocks | |
{ | |
"properties": { | |
"d3version": { | |
"type": "string", | |
"index": "not_analyzed" | |
} | |
} | |
} | |
PUT /blockbuilder/_mappings/blocks | |
{ | |
"properties": { | |
"d3modules": { | |
"type": "string", | |
"index": "not_analyzed" | |
} | |
} | |
} | |
# Lookup a text string | |
GET /blockbuilder/blocks/_search | |
{ | |
"query": { | |
"match": { | |
"description": "custom ease" | |
} | |
} | |
} | |
GET /blockbuilder/blocks/_search | |
{ | |
"query": { | |
"match": { | |
"code": "circle" | |
} | |
} | |
} | |
# prototype of a best-match query for searching the text fields | |
# https://www.elastic.co/guide/en/elasticsearch/guide/current/_tuning_best_fields_queries.html | |
GET /blockbuilder/blocks/_search | |
{ | |
"query": { | |
"dis_max": { | |
"queries": [ | |
{ "match": { "description": "circle" }}, | |
{ "match": { "readme": "circle" }}, | |
{ "match": { "code": "circle" }} | |
], | |
"tie_breaker": 0.1 | |
} | |
} | |
} | |
GET /blockbuilder/blocks/_search | |
{ | |
"size": 0, | |
"query": { | |
"match": { "description": "" } | |
}, | |
"aggs": { | |
"users": { | |
"terms" : { "field": "userId" } | |
}, | |
"latest": { | |
"max": {"field": "created_at" } | |
}, | |
"earliest": { | |
"min": {"field": "created_at" } | |
} | |
} | |
} | |
GET /blockbuilder/blocks/_search | |
{ | |
"query": { | |
"match": { | |
"userId": "enjalot" | |
} | |
} | |
} | |
GET /blockbuilder/blocks/_search | |
{ | |
"query": { | |
"filtered": { | |
"query": { | |
"match_all": {} | |
}, | |
"filter": { | |
"bool": { | |
"must": [{ | |
"term": { | |
"userId": "mbostock" | |
} | |
}] | |
} | |
} | |
} | |
}, | |
"size": "100" | |
} | |
GET /blockbuilder/blocks/_search | |
{ | |
"query": { | |
"filtered": { | |
"query": { "match": { "api": "d3.svg.line"} }, | |
"filter": { | |
"bool": { | |
"must": [ | |
{"match": { "userId": "enjalot" }}, | |
{"range": { "updated_at": { "gte": "2015-12-01T00:00:00Z" }}} | |
] | |
} | |
} | |
} | |
} | |
} | |
GET /blockbuilder/blocks/_search | |
{ | |
"query": { | |
"dis_max": { | |
"queries": [{ | |
"match": { | |
"description": "circle" | |
} | |
}, { | |
"match": { | |
"readme": "circle" | |
} | |
}, { | |
"match": { | |
"code": "circle" | |
} | |
}], | |
"tie_breaker": 0.1 | |
}}, | |
"aggs": { | |
"users": { | |
"terms": { | |
"field": "userId" | |
} | |
}, | |
"latest": { | |
"max": { | |
"field": "created_at" | |
} | |
}, | |
"earliest": { | |
"min": { | |
"field": "created_at" | |
} | |
} | |
}, | |
"size": 100 | |
} | |
GET /blockbuilder/blocks/_search | |
{ | |
"query": { | |
"filtered": { | |
"query": { | |
"dis_max": { | |
"queries": [{ | |
"match": { | |
"description": "circle" | |
} | |
}, { | |
"match": { | |
"readme": "circle" | |
} | |
}, { | |
"match": { | |
"code": "circle" | |
} | |
}], | |
"tie_breaker": 0.1 | |
}}, | |
"filter": { | |
"bool": { | |
"must": [ | |
{"match": { "userId": "enjalot" }}, | |
{"match": { "api": "d3.layout.force" }} | |
] | |
} | |
} | |
}} | |
} | |
GET /blockbuilder/blocks/_search | |
{ | |
"query": { | |
"match": { | |
"api": "d3.layout.pack" | |
} | |
} | |
} | |
# Lookup gists with a CSV file | |
GET /blockbuilder/blocks/_search | |
{ | |
"query": { | |
"wildcard": { | |
"filenames": "*.csv" | |
} | |
} | |
} | |
GET /blockbuilder/blocks/_search | |
{ | |
"size": 0, | |
"aggs": { | |
"all_api": { | |
"terms": { | |
"field": "api", | |
"size": 0 | |
} | |
} | |
} | |
} | |
GET /blockbuilder/blocks/_search | |
{ | |
"aggs": { | |
"all_colors": { | |
"terms": { "field": "colors" } | |
} | |
} | |
} | |
GET /blockbuilder/blocks/_search | |
{ | |
"aggs": { | |
"all_files": { | |
"terms": { "field": "filenames" } | |
} | |
} | |
} | |
GET /blockbuilder/blocks/_search | |
{ | |
"query": { | |
"match_all": {} | |
}, | |
"sort": { "updated_at":{ "order": "asc" }} | |
} | |
GET /blockbuilder/blocks/_search | |
{ | |
"query": { | |
"match_all": {} | |
}, | |
"sort": { "created_at":{ "order": " desc" }} | |
} | |
# get all the users by count | |
GET /blockbuilder/blocks/_search | |
{ | |
"size": 0, | |
"aggs": { | |
"users": { | |
"terms" : { "field": "userId", "size":0 } | |
} | |
} | |
} |
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
DELETE /bbindexer | |
PUT /bbindexer | |
{ | |
"mappings": { | |
"blocks": { | |
"properties": { | |
"script": { | |
"type": "string", | |
"index": "not_analyzed" | |
}, | |
"filename": { | |
"type": "string", | |
"index": "not_analyzed" | |
}, | |
"since": { | |
"type": "date" | |
}, | |
"ranAt": { | |
"type": "date" | |
} | |
} | |
} | |
} | |
} | |
GET /bbindexer/scripts/_search | |
{ | |
"query": { | |
"match_all": {} | |
}, | |
"sort": { "ranAt":{ "order": "desc" }} | |
} | |
GET /bbindexer/scripts/_search | |
{ | |
"query": { | |
"match": { "script": "meta"} | |
}, | |
"sort": { "ranAt":{ "order": "desc" }} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment