Evaluating data against two fields

I'm very new in elasticsearch and I think this is a really powerful tool.
In my project I need to perform a query where the two or more fields may be correlated.
In order to solve this problem I have used scripting and created the next solution:

curl -XPOST 'http://localhost:9200/my_index/_search?pretty=true' -d '{
"query":{
"custom_score" : {
"query" : {
"query_string" : {
"query" : "*"
}
},
"script" : "_score = _source.field1 != _source.field2 ? 1 : -1;"
}
},
"min_score": 0.0
}'

I'm wondering if there are a more efficient manner to perform the same type of query and if
the community can point me a direction?

Thank you in advance.