Skip to content

Instantly share code, notes, and snippets.

@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 / boost_by_id.json
Created August 20, 2014 10:02
boost specific titles
{
"query": {
"function_score": {
"query": {
"multi_match": {
"query": "gospel",
"fields": [
"title.raw^60",
"authors.raw^40",
"subjects.raw^20",
@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 / rsyslog compile error
Created August 26, 2014 14:30
rsyslog compile error
msg.c: In function 'getJSONPropVal':
msg.c:2736:3: warning: 'json_object_object_get' is deprecated (declared at /usr/include/json/json_object.h:217) [-Wdeprecated-declarations]
field = json_object_object_get(parent, (char*)leaf);
^
msg.c: In function 'msgGetJSONPropJSON':
msg.c:2789:2: warning: 'json_object_object_get' is deprecated (declared at /usr/include/json/json_object.h:217) [-Wdeprecated-declarations]
*pjson = json_object_object_get(parent, (char*)leaf);
^
In file included from /usr/include/json/linkhash.h:16:0,
from /usr/include/json/json.h:22,
{
"size": 10,
"query": {
"filtered": {
"query": {
"bool": {
"should": [
{
"multi_match": {
"analyzer": "whitespace_shingle",
@radu-gheorghe
radu-gheorghe / limit.json
Created September 11, 2014 08:45
limit filter
{
"from": 0,
"size": 25,
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"bool": {
@radu-gheorghe
radu-gheorghe / repro.sh
Created February 5, 2015 09:51
Elasticsearch significant terms background filtering size oddities
curl -XDELETE localhost:9200/test
curl -XPOST localhost:9200/test/test -d '{"a": "foo"}'
curl -XPOST localhost:9200/test/test -d '{"a": "foo"}'
curl -XPOST localhost:9200/test/test -d '{"a": "foo2"}'
curl -XPOST localhost:9200/test/test -d '{"a": "foo2"}'
curl -XPOST localhost:9200/test/test -d '{"a": "foo"}'
curl localhost:9200/test/_refresh
# ElasticsearchIllegalArgumentException[supersetFreq > supersetSize, in JLHScore.score(..)]
curl 'localhost:9200/test/_search?pretty&search_type=count' -d '{
@radu-gheorghe
radu-gheorghe / example.log.parsed.snippet
Created September 23, 2015 06:14
logstash json_lines issue
{"message":"proxy-435.dialup.xtra.co.nz - - [22/Apr/2009:18:52:51 +1200] \"GET /images/photos/455.jpg HTTP/1.1\" 200 986 \"-\" \"Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; en) AppleWebKit/525.13 (KHTML, like Gecko) Version/3.1 Safari/525.13\" \"-\"","@version":"1","@timestamp":"2015-04-16T17:35:24.585Z","host":"rgheorghe-suse.rgheorghe-local","path":"/opt/example.log.raw","clientip":"proxy-435.dialup.xtra.co.nz","ident":"-","auth":"-","timestamp":"22/Apr/2009:18:52:51 +1200","verb":"GET","request":"/images/photos/455.jpg","httpversion":"1.1","response":"200","bytes":"986","referrer":"\"-\"","agent":"\"Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; en) AppleWebKit/525.13 (KHTML, like Gecko) Version/3.1 Safari/525.13\""}
{"message":"proxy-435.dialup.xtra.co.nz - - [22/Apr/2009:18:52:51 +1200] \"GET /images/nav/tab_left_middle.gif HTTP/1.1\" 200 1020 \"-\" \"Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; en) AppleWebKit/525.13 (KHTML, like Gecko) Version/3.1 Safari/525.13\" \"-\"","@version":"1",
@radu-gheorghe
radu-gheorghe / _alltest.sh
Created October 30, 2012 15:27
Elasticsearch - include in _all with index=no
echo ===Removing everything===
curl -XDELETE localhost:9200/test
echo
echo ===Putting empty index===
curl -XPUT localhost:9200/test
echo
echo ====Putting mapping===
curl -XPUT localhost:9200/test/test/_mapping -d '{
"test": {
"properties": {
@radu-gheorghe
radu-gheorghe / copy_es_index.bash
Created November 5, 2012 09:30
copy one Elasticesarch index to another
#!/bin/bash
CURRENTINDEX="test"
NEWINDEX="newindex"
#where the indices are stored within the DATADIR
INDICESDIR=/var/lib/elasticsearch/elasticsearch/nodes/0/indices/
#get the metadata for the current index
curl localhost:9200/$CURRENTINDEX/_settings?pretty=true > /tmp/settings
curl localhost:9200/$CURRENTINDEX/_mapping?pretty=true > /tmp/mappings