Created
May 4, 2017 02:57
-
-
Save dushujun/ffd604c3dfea7c277505e721b3447e2d to your computer and use it in GitHub Desktop.
elasticsearch query by string length
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
{ | |
"query": { | |
"bool": { | |
"must": { | |
"script": { | |
"script": { | |
"inline": "doc['被执行人姓名/名称.raw'].getValue().length() < 4 ", | |
"lang": "painless" | |
} | |
} | |
} | |
} | |
} | |
} |
am I only one that gets
oc['log_processed.request_id'].size() > 0 && doc['log_processed.request_id'].value.length() < 4
^---- HERE
error ?
am I only one that gets
oc['log_processed.request_id'].size() > 0 && doc['log_processed.request_id'].value.length() < 4 ^---- HERE
error ?
If a record dose not have the log_processed
field, it will gave you this error.
I think the correct query is:
doc['log_processed'] != null && doc['log_processed.request_id'].size() > 0 && doc['log_processed.request_id'].value.length() < 4
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
That query is wrong!
Error: A document doesn't have a value for a field! Use doc[].size()==0 to check if a document is missing a field!
The correct query is: