Created
November 7, 2018 12:04
-
-
Save djptek/32199be96ca45dcc76cf5e3dc80707bc to your computer and use it in GitHub Desktop.
looking into TERMS aggs vs index false
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
# looking into TERMS aggs vs index false | |
# start clean | |
DELETE test | |
# define an index with two fields, with index | |
# set to true & false | |
PUT test | |
{ | |
"mappings": { | |
"_doc": { | |
"properties": { | |
"index_true": { | |
"type": "keyword", | |
"index": "true" | |
}, | |
"index_false": { | |
"type": "keyword", | |
"index": "false" | |
} | |
} | |
} | |
} | |
} | |
# index example documents | |
PUT test/_doc/1 | |
{ | |
"index_true": "indexed1", | |
"index_false": "ignored1" | |
} | |
PUT test/_doc/2 | |
{ | |
"index_true": "indexed2", | |
"index_false": "ignored2" | |
} | |
# search for indexed content, this works | |
GET test/_search | |
{ | |
"query": { | |
"regexp": { | |
"index_true": "index.*" | |
} | |
} | |
} | |
# search for indexed content, this fails with | |
# HTTP/1.1 400 Bad Request | |
GET test/_search | |
{ | |
"query": { | |
"regexp": { | |
"index_false": "ignore.*" | |
} | |
} | |
} | |
# aggs vs indexed keyword field, expected result: | |
# "my_indexed_field_terms":{ | |
# "doc_count_error_upper_bound":0, | |
# "sum_other_doc_count":0, | |
# "buckets":[ | |
# {"key":"indexed1","doc_count":1}, | |
# {"key":"indexed2","doc_count":1} | |
# ] | |
# } | |
GET test/_search | |
{ | |
"size": 0, | |
"aggs": { | |
"my_indexed_field_terms": { | |
"terms": { | |
"field": "index_true", | |
"size": 10 | |
} | |
} | |
} | |
} | |
# aggs vs indexed keyword field, expected result: | |
# "my_indexed_field_terms":{ | |
# "doc_count_error_upper_bound":0, | |
# "sum_other_doc_count":0, | |
# "buckets":[ | |
# {"key":"ignored1","doc_count":1}, | |
# {"key":"ignored2","doc_count":1} | |
# ] | |
# } | |
GET test/_search | |
{ | |
"size": 0, | |
"aggs": { | |
"my_NOT_indexed_field_terms": { | |
"terms": { | |
"field": "index_false", | |
"size": 10 | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment