Skip to content

Instantly share code, notes, and snippets.


Matt Weber mattweber

View GitHub Profile
mattweber /
Last active Nov 9, 2019
Elasticsearch 7.4.2 min/max aggregation with missing value returns invalid results
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_REPLICAS;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSearchResponse;
import static;
import org.elasticsearch.Version;

Keybase proof

I hereby claim:

  • I am mattweber on github.
  • I am mrweber ( on keybase.
  • I have a public key whose fingerprint is F5DF 97DB 70D1 6E14 2282 4539 A504 BE51 687C 61EA

To claim this, I am signing this object:

mattweber /
Last active Jan 8, 2021
Multi-word query time synonyms in elasticsearch.
# delete old index if exists
curl -XDELETE 'http://localhost:9200/syns?pretty'
# create index with synonym analyzer and mapping
curl -XPUT 'http://localhost:9200/syns?pretty' -d '{
"settings" : {
"number_of_replicas": 0,
"number_of_shards": 1,
"index": {
"analysis": {
mattweber / README
Last active Dec 13, 2015
Using ElasticSearch To Find The Best Time To Ask Questions on StackOverflow
Use to parse and index the StackOverflow posts.xml file into an existing index.
Usage: [options] file
-h, --help show this help message and exit
-s SERVER, --server=SERVER
ElasticSearch Server
-i INDEX, --index=INDEX
Index name to use
mattweber / README.txt
Created Mar 1, 2012
ElasticSearch Multi-Select Faceting Example
View README.txt
This is an example how to perform multi-select faceting in ElasticSearch.
Selecting multiple values from the same facet will result in an OR filter between each of the values:
(facet1.value1 OR facet1.value2)
Faceting on more than one facet will result in an AND filter between each facet:
(facet1.value1 OR facet1.value2) AND (facet2.value1)
I have chosen to update the counts for each facet the selected value DOES NOT belong to since we are performing an AND between each facet. I have included an example that shows how to keep the counts if you don't want to do this (
mattweber / query
Created Feb 22, 2012
NOT WITHIN queries in ElasticSearch
View query
## For comment on
"include": {
"span_term": {"FIELD":"fish"}
View failed query (has filter)
curl -XGET 'http://localhost:9200/test/_search?pretty=true' -d '{
"should": [
"filter" : {
View mapping
curl -XPUT 'http://localhost:9200/testing' -d '{
"mappings" : {
"testa" : {
"_source" : {
"enabled" : true
"properties" : {
"field1" : {"type" : "string", "store" : "yes"},
"field2" : {"type" : "string", "store" : "yes"}
View config
tokenizer: keyword
filter: lowercase