Skip to content

Instantly share code, notes, and snippets.

@radu-gheorghe
radu-gheorghe / nested filter
Created August 20, 2014 09:43
nested query turned filter
{
"size": 100,
"query": {
"filtered": {
"query": {
"multi_match": {
"query": "gospel",
"fields": [
"title.raw^60",
"authors.raw^40",
@radu-gheorghe
radu-gheorghe / delete_by_query_stats.sh
Created April 14, 2014 10:50
deleted stats are not updated when running delete by query in Elasticsearch 1.1.0
#!/bin/sh
echo
echo '==========================='
echo 'Creating an empty index'
echo '==========================='
curl -XDELETE localhost:9200/test
curl -XPOST localhost:9200/test/ -d '{"settings": {"index.number_of_shards": 1}}'
echo
@radu-gheorghe
radu-gheorghe / test-logsene
Created September 24, 2013 15:40
Logsene test dashboard
{
"title": "another test application",
"services": {
"query": {
"idQueue": [
2,
3,
4
],
"list": {
@radu-gheorghe
radu-gheorghe / match_array.bash
Created July 15, 2013 14:15
match query on an array
curl -XDELETE localhost:9200/test
curl -XPUT localhost:9200/test -d '{
"settings": {
"number_of_shards": 1
}
}'
curl -XPUT localhost:9200/test/test/1 -d '{
"tags": "foo"
}'
curl -XPUT localhost:9200/test/test/2 -d '{
@radu-gheorghe
radu-gheorghe / sharp_search.sh
Created July 10, 2013 08:43
index and search for a value containing #
curl -XDELETE localhost:9200/test1
curl -XPUT localhost:9200/test1
curl -XPUT localhost:9200/test1/test/_mapping -d '{
"test": {
"properties": {
"foo": {
"type": "string",
"index": "not_analyzed"
}
}
@radu-gheorghe
radu-gheorghe / id_path_overwrite.sh
Created July 10, 2013 08:15
Elasticsearch: If you create a mapping with the ID field pointing to a certain path, inserting two docs with the same ID should overwrite, instead of throwing an error. Unless you specify to "create" documents
#!/bin/bash
curl -XDELETE localhost:9200/test
curl -XPUT localhost:9200/test
curl -XPUT localhost:9200/test/test/_mapping -d '{
"test": {
"_id": {
"path": "foo"
}
}
@radu-gheorghe
radu-gheorghe / track_scores.bash
Created April 28, 2013 09:00
Elasticsearch should still show scores for each hit when sorting on a field and track_scores is true
curl -XDELETE localhost:9200/test
curl -XPUT localhost:9200/test/test/1 -d '{"foo": "bar"}'
curl -XPOST localhost:9200/test/_refresh
echo
echo "==============="
echo -e "\e[00;32mCORRECT: SCORE IS SHOWN WHEN SORTING ON SCORE\e[00m"
echo "==============="
curl 'localhost:9200/test/test/_search?q=bar&pretty' 2>/dev/null | grep score
echo
echo "==============="
@radu-gheorghe
radu-gheorghe / multiple_child_levels.bash
Created April 23, 2013 09:04
multiple parent-child level query with Elasticsearch
curl -XDELETE localhost:9200/test/
curl -XPUT localhost:9200/test/
curl -XPUT localhost:9200/test/son/_mapping -d '{
"son": {
"_parent": {
"type": "mother"
}
}
}'
curl -XPUT localhost:9200/test/daughter/_mapping -d '{
@radu-gheorghe
radu-gheorghe / includes_excludes.sh
Created March 28, 2013 18:08
Test for includes and excludes options of _source
curl -XDELETE localhost:9200/test1/
curl -XDELETE localhost:9200/test2/
curl -XPUT localhost:9200/test1/
curl -XPUT localhost:9200/test1/source_includes/_mapping -d '{
"source_includes": {
"_source": {
"includes": [ "included" ]
}
}
}'
@radu-gheorghe
radu-gheorghe / parent_child_ttl.sh
Created March 8, 2013 15:04
different TTL for parents and children test. Assumes: $ tail -1 /etc/elasticsearch/elasticsearch.yml indices.ttl.interval: 1s
curl -XDELETE localhost:9200/test
curl -XPUT localhost:9200/test
curl -XPUT localhost:9200/test/p/_mapping -d '{
"p" :{
"_ttl" : { "enabled" : true, "default": "10s" }
}
}'
curl -XPUT localhost:9200/test/c/_mapping -d '{
"c" :{
"_ttl" : { "enabled" : true, "default": "20s" }