Script to iterate field by field in a doc

(Arun Prakash) #1

Hi all,

I am using custom score to obtain my expected result, such a way i need to iterate the fields in a document and have to do some score values for specified fields in the document, i have tried to get the fields of the doc but Oops!, cud any one help me?

i need the script as like this....

String[] fieldNames = {"field1","field2","field3"};
for (String fieldName : fieldNames) {
if(fieldName == "myExpectedField" && fieldName.value == "epectedValue"){
_score = _score+1

and if is there any other way to achieve this please let me know? Thanks in advance

(Wanglifengwf) #2

you can use :

String str;for(e in _source.keySet()){ str +=_source[e]};return str;

(system) #3