Created
September 24, 2015 21:53
-
-
Save eemp/0e3df8552501bc2a79a6 to your computer and use it in GitHub Desktop.
Find Elasticsearch records where a field is an array instead of a simple String
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
curl -w "\n" -XDELETE localhost:9200/scrap | |
curl -w "\n" -XPUT localhost:9200/scrap/ -d ' | |
index : | |
number_of_replicas : 0 | |
' | |
curl -w "\n" -XPUT localhost:9200/scrap/script-demo/1?refresh=1 -d '{ | |
"fieldA" : "test string 1" | |
}' | |
curl -w "\n" -XPUT localhost:9200/scrap/script-demo/2?refresh=1 -d '{ | |
"fieldA" : [ | |
"test string 1", | |
"test string 2" | |
] | |
}' | |
curl -w "\n" -XPUT localhost:9200/scrap/script-demo/3?refresh=1 -d '{ | |
"fieldA" : [ | |
"test string 1" | |
] | |
}' | |
curl -w "\n" -XPOST localhost:9200/scrap/script-demo/_search -d '{ | |
"query" : { | |
"filtered" : { | |
"filter" :{ | |
"script" : { | |
"script" : "_source.fieldA.getClass() != String" | |
} | |
} | |
} | |
} | |
}' | python -m json.tool |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment