Filtering responsed data from ElasticSearch -


i want ask you, if there way filter searchrequestbuilder srb in elasticsearch. have index consists of companies. every company has document english language , may has documents other languages. want bring companies has document selected user language , if company hasn't document language bring me english.

is there way this? thank in advance.

answer updated return companies using scrolling api.

querybuilder qb = termquery("document", "english");  searchresponse scrollresp = client.preparesearch(test)     .addsort(fieldsortbuilder.doc_field_name, sortorder.asc)     .setscroll(new timevalue(60000))     .setquery(qb)     .setsize(100).execute().actionget(); //max of 100 hits returned each scroll //scroll until no hits returned {      (searchhit hit : scrollresp.gethits().gethits()) {     //handle hit...      }      scrollresp =client.preparesearchscroll(scrollresp.getscrollid()).setscroll(new      timevalue(60000)).execute().actionget();    }     while(scrollresp.gethits().gethits().length != 0);  // 0 hit mark end of scroll , while loop. 

and can use if block returning companies english document if no document found other languages.

something this

if(searchresponse1 == null) //searchresponse non english language { (search documents in english) } 

hope helps


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -