Skip to content

Instantly share code, notes, and snippets.

@jtibshirani
jtibshirani / optimize_bbox_failure
Created May 1, 2014 20:10
optimize_bbox for geo_distance filters can cause missing results
curl -XDELETE 'localhost:9200/geo_test'
curl -XPOST 'localhost:9200/geo_test' -d '
{
"settings": {
"number_of_replicas": 0,
"number_of_shards": 1
},
@jtibshirani
jtibshirani / nested_field_mapping
Created May 1, 2014 21:09
for nested queries, field mapper doesn't take path into account
curl -XDELETE 'localhost:9200/mapper_test'
curl -XPOST 'localhost:9200/mapper_test' -d '
{
"settings": {
"number_of_replicas": 0,
"number_of_shards": 1
},
@jtibshirani
jtibshirani / nested_query_highlighting
Last active August 29, 2015 14:02
highlighting doesn't work for nested queries, even with _source enabled
curl -XDELETE 'localhost:9200/test'
curl -XPOST 'localhost:9200/test' -d '
{
"settings": {
"number_of_replicas": 0,
"number_of_shards": 1
},
"mappings": {
@jtibshirani
jtibshirani / search_quote_analyzer
Created March 31, 2015 23:16
search_quote_analyzer always added to mapping when position_offset_gap is specified
curl -XDELETE 'localhost:9200/test'
curl -XPOST 'localhost:9200/test' -d '
{
"settings": {
"number_of_replicas": 0,
"number_of_shards": 1
},
"mappings": {
curl -XDELETE localhost:9200/test
curl -XPOST localhost:9200/test -d '{
"settings" : {
"number_of_shards" : 1
},
"mappings": {
"doc": {
"properties": {
"field": {
@jtibshirani
jtibshirani / suggest_stats
Created April 18, 2018 17:33
Inconsistent behavior when requesting stats for the 'suggest' metric
> PUT test
{
"acknowledged": true,
"shards_acknowledged": true,
"index": "test"
}
> GET /_stats/suggest
{
"_shards": {
@jtibshirani
jtibshirani / dynamic_field_templates
Last active May 1, 2018 05:23
When putting new dynamic templates, all existing templates are overwritten.
PUT authors
PUT authors/_mapping/_doc
{
"dynamic_templates":[
{
"template_1":{
"match":"*",
"mapping":{
"type":"long"
@jtibshirani
jtibshirani / completion_suggester_regex
Last active May 1, 2018 05:38
Completion suggester fails when empty regex query is provided.
PUT music
{
"mappings": {
"_doc" : {
"properties" : {
"suggest" : {
"type" : "completion",
"contexts": [
{
"name": "place_type",
@jtibshirani
jtibshirani / index_to_alias_authorization
Last active May 15, 2018 00:18
Authorization failure when indexing document with new mappings to alias.
# Create an index called 'test', and an alias to it called 'test_alias'.
curl -XPUT -u elastic:<admin_password> http://localhost:9200/test -H 'Content-Type: application/json'
curl -XPOST -u elastic:<admin_password> http://localhost:9200/_aliases -H 'Content-Type: application/json' -d '{
"actions" : [
{ "add" : { "index" : "test", "alias" : "test_alias" } }
]
}'
# Set ip a user called 'test_user' that is allowed to write to 'test_alias'.
curl -XPOST -u elastic:<admin_password> http://localhost:9200/_xpack/security/role/test_role -H 'Content-Type: application/json' -d '{
@jtibshirani
jtibshirani / terms_wildcard_on_index
Created September 28, 2018 21:55
Consider deprecating/ removing support for wildcards in `_index` term queries.
PUT index
PUT index/_doc/1
{
"key": "value"
}
POST index/_search
{
"query": {