How to check for true condition in elasticsearch scripting? -


i have documents boolean field

 {     "field1" : true } 

now want check, whether "field1" true or not, , run query if true. how can using scripts in elasticsearch?

daniel's approach superior literally using scripts because faster, if had need within script, need check if value indexed 't' or 'f' in elasticsearch 1.x. in elasticsearch 2.x , above, lucene changed using more traditional 1 , 0.

es 2.x (and above):

{   "query" : {     "bool" : {       "filter" : [ {         "script" : {           "inline" : "doc['field1'].value == 1"         }       } ]     }   } } 

es 1.x:

{   "query" : {     "filtered" : {       "filter" : {         "script" : {           "script" : "doc['field1'].value == 't'"         }       }     }   } } 

it's bad idea ever use script unless required cannot done without one, such compare fields simultaneously ensure have same value.


Comments

Popular posts from this blog

php - Zend Framework / Skeleton-Application / Composer install issue -

c# - Better 64-bit byte array hash -

python - PyCharm Type error Message -