Skip to content

Instantly share code, notes, and snippets.

@ianAndrewClark
Created December 14, 2012 11:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ianAndrewClark/4284891 to your computer and use it in GitHub Desktop.
Save ianAndrewClark/4284891 to your computer and use it in GitHub Desktop.
problem with boolean fields
echo "\nSetup test index"
curl -XDELETE "http://localhost:9200/booltest"
curl -XPUT 'http://localhost:9200/booltest/' -d '
{
"settings": {
"index": {
"number_of_shards": 1,
"number_of_replicas": 0
},
"mappings": {
"thing": {
"properties": {
"flag": { "type" : "boolean" }
},
"_all": {
"enabled": "false"
}
}
}
}
}
'
echo "\nok to start"
curl -XGET "http://localhost:9200/_cluster/health?wait_for_status=green&timeout=10s"
echo "\ndoc 1"
curl -XPUT 'http://localhost:9200/booltest/thing/1' -d '
{
"flag": true
}
'
echo "\ndoc 2"
curl -XPUT 'http://localhost:9200/booltest/thing/2' -d '
{
"flag": true
}
'
echo "\ndoc 3"
curl -XPUT 'http://localhost:9200/booltest/thing/3' -d '
{
"flag": false
}
'
echo "\ndoc 4"
curl -XPUT 'http://localhost:9200/booltest/thing/4' -d '
{
"flag": false
}
'
echo "\nrefreshing....."
curl -XPOST 'http://localhost:9200/booltest/_refresh?pretty=true'
echo "\ndo a search - see the terms....."
curl -XGET 'http://localhost:9200/booltest/thing/_search?pretty=true' -d '
{
"from": 0,
"size": 0,
"query": { "match_all" : {}},
"facets": {
"flag_terms": {
"terms": {
"field": "flag"
}
}
}
}
'
echo "\ndo a search - filter for flag=true fails.... should be 2!"
curl -XGET 'http://localhost:9200/booltest/thing/_search?pretty=true' -d '
{
"from": 0,
"size": 0,
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"and": {
"filters": [
{
"term": {
"flag": true
}
}
]
}
}
}
},
"facets": {
"flag_terms": {
"terms": {
"field": "flag"
}
}
}
}
'
echo "\nprint ES info"
curl -XGET http://localhost:9200/
echo "\nprint java version info"
java -version
Setup test index
{"ok":true,"acknowledged":true}{"ok":true,"acknowledged":true}
ok to start
{"cluster_name":"elasticsearch","status":"green","timed_out":false,"number_of_nodes":1,"number_of_data_nodes":1,"active_primary_shards":2,"active_shards":2,"relocating_shards":0,"initializing_shards":0,"unassigned_shards":0}
doc 1
{"ok":true,"_index":"booltest","_type":"thing","_id":"1","_version":1}
doc 2
{"ok":true,"_index":"booltest","_type":"thing","_id":"2","_version":1}
doc 3
{"ok":true,"_index":"booltest","_type":"thing","_id":"3","_version":1}
doc 4
{"ok":true,"_index":"booltest","_type":"thing","_id":"4","_version":1}
refreshing.....
{
"ok" : true,
"_shards" : {
"total" : 1,
"successful" : 1,
"failed" : 0
}
}
do a search - see the terms.....
{
"took" : 4,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"failed" : 0
},
"hits" : {
"total" : 4,
"max_score" : 1.0,
"hits" : [ ]
},
"facets" : {
"flag_terms" : {
"_type" : "terms",
"missing" : 0,
"total" : 4,
"other" : 0,
"terms" : [ {
"term" : "F",
"count" : 2
}, {
"term" : "t",
"count" : 1
}, {
"term" : "T",
"count" : 1
} ]
}
}
}
do a search - filter for flag=true fails.... should be 2!
{
"took" : 1,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 1.0,
"hits" : [ ]
},
"facets" : {
"flag_terms" : {
"_type" : "terms",
"missing" : 0,
"total" : 1,
"other" : 0,
"terms" : [ {
"term" : "T",
"count" : 1
} ]
}
}
}
print ES info
{
"ok" : true,
"status" : 200,
"name" : "Human Fly",
"version" : {
"number" : "0.20.1",
"snapshot_build" : false
},
"tagline" : "You Know, for Search"
}
print java version info
java version "1.7.0_09"
Java(TM) SE Runtime Environment (build 1.7.0_09-b05)
Java HotSpot(TM) 64-Bit Server VM (build 23.5-b02, mixed mode)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment