elasticsearch is taking longer time while doing update and search simultaneously

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

elasticsearch is taking longer time while doing update and search simultaneously

bagui
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 [hidden email].
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.
--
laltu
Software Engineer
Reply | Threaded
Open this post in threaded view
|

Re: elasticsearch is taking longer time while doing update and search simultaneously

vineeth mohan-2
Hello Subhadip , 


What exactly are you trying to achieve using this code.

 updateResponse = client.prepareUpdate(index, type, id)
  .setDoc(jsonBuilder()
  .startObject().field("view_mode", "read")
  .endObject())
.setDocAsUpsert(true)
.setFields("_source")
.setTimeout("10000")

I was wondering where the modification data is given.

Thanks
            Vineeth



On Fri, Aug 22, 2014 at 7:00 PM, Subhadip Bagui <[hidden email]> wrote:
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 [hidden email].
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.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAGdPd5kp10tiuNpPN4wW1mso_-MLxfB1zBZULM%2BpSeSG6o75dg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: elasticsearch is taking longer time while doing update and search simultaneously

bagui
Hi,

In this code I'm trying to update the field "view_mode" value as "read".


On Friday, August 22, 2014 11:25:45 PM UTC+5:30, vineeth mohan wrote:
Hello Subhadip , 


What exactly are you trying to achieve using this code.

 updateResponse = client.prepareUpdate(index, type, id)
  .setDoc(jsonBuilder()
  .startObject().field("view_mode", "read")
  .endObject())
.setDocAsUpsert(true)
.setFields("_source")
.setTimeout("10000")

I was wondering where the modification data is given.

Thanks
            Vineeth



On Fri, Aug 22, 2014 at 7:00 PM, Subhadip Bagui <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="8RiwxGb6b44J" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">i.b...@...> wrote:
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();
<a href="http://logger.info" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Flogger.info\46sa\75D\46sntz\0751\46usg\75AFQjCNGOfWV_MqSEYOUyz77vBSYyM6smOg';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Flogger.info\46sa\75D\46sntz\0751\46usg\75AFQjCNGOfWV_MqSEYOUyz77vBSYyM6smOg';return true;">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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="8RiwxGb6b44J" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">elasticsearc...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/elasticsearch/945425a0-69c2-46bd-b63f-a23bc6dc455c%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" onmousedown="this.href='https://groups.google.com/d/msgid/elasticsearch/945425a0-69c2-46bd-b63f-a23bc6dc455c%40googlegroups.com?utm_medium\75email\46utm_source\75footer';return true;" onclick="this.href='https://groups.google.com/d/msgid/elasticsearch/945425a0-69c2-46bd-b63f-a23bc6dc455c%40googlegroups.com?utm_medium\75email\46utm_source\75footer';return true;">https://groups.google.com/d/msgid/elasticsearch/945425a0-69c2-46bd-b63f-a23bc6dc455c%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" onmousedown="this.href='https://groups.google.com/d/optout';return true;" onclick="this.href='https://groups.google.com/d/optout';return true;">https://groups.google.com/d/optout.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/e1485ab2-6aac-4ef2-830d-5d11123fd7f6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
laltu
Software Engineer