Hi,
I'm doing update in elasticsearch document and the same time one rest api
is calling for search results. Below is my code.
public String updateElasticsearchDocument(String index, String type,
List<String> indexID) {
Client client = ESClientFactory.getInstance();
UpdateResponse updateResponse = null;
JSONObject jsonResponse = new JSONObject();
JSONObject json =new JSONObject();
int i=1;
try {
for(String id : indexID)
{
updateResponse = client.prepareUpdate(index, type, id)
.setDoc(jsonBuilder()
.startObject().field("view_mode", "read")
.endObject())
.setDocAsUpsert(true)
.setFields("_source")
.setTimeout("10000")
.execute().actionGet();
logger.info("updating the document for type= "+ updateResponse.getType()+
" for id= "+ updateResponse.getId());
json.put("indexID"+i, updateResponse.getId());
i++;
}
jsonResponse.put("updated_index", json);
} catch (ActionRequestValidationException e) {
logger.warn(this.getClass().getName() + ":" + "updateDocument: "
+ e.getMessage(), e);
}
catch (ElasticsearchException e) {
logger.warn(this.getClass().getName() + ":" + "updateDocument: "
+ e.getMessage(), e);
e.printStackTrace();
} catch (IOException e) {
logger.warn(this.getClass().getName() + ":" + "updateDocument: "
+ e.getMessage(), e);
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return jsonResponse.toString();
}
*the search query is :*
POST /monitoring/quota-management/_search
{
"query": {"match": {
"view_mode": "read"
}},
"sort": [
{
"_timestamp": {
"order": "desc"
}
}
],
"size": 10
}
Now, I have to wait for like 40-50 seconds to get the updated search
result. This is affecting the production application.
Please let me know what needs to be done here to minimizes the time taken.
Thanks,
Subhadip
--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/945425a0-69c2-46bd-b63f-a23bc6dc455c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.