How do I query GCP Search APIs asynchronously from an App Engine instance?
up vote
1
down vote
favorite
I need to search my App Engine indexed documents using the Search API. From what I can tell, the Search API can only be referenced with the google.appengine APIs for the standard environment.
My problem is that some hydrating, flushing, and querying takes longer than 60 seconds. I need to return a response from app engine, continue processing the request in the background, then publish the results to Pub/Sub. However, I can spawn threads or use background_thread in the standard environment. I'd switch to the flexible environment, but I cannot use the Python Search API library.
Is my only option to switch to the flex environment, and use REST APIs?
google-app-engine google-cloud-platform google-search-api google-app-engine-python app-engine-flexible
add a comment |
up vote
1
down vote
favorite
I need to search my App Engine indexed documents using the Search API. From what I can tell, the Search API can only be referenced with the google.appengine APIs for the standard environment.
My problem is that some hydrating, flushing, and querying takes longer than 60 seconds. I need to return a response from app engine, continue processing the request in the background, then publish the results to Pub/Sub. However, I can spawn threads or use background_thread in the standard environment. I'd switch to the flexible environment, but I cannot use the Python Search API library.
Is my only option to switch to the flex environment, and use REST APIs?
google-app-engine google-cloud-platform google-search-api google-app-engine-python app-engine-flexible
Have you tryindex.search_async()
?
– MatrixTai
Nov 12 at 7:50
I don't think that will work. Let's say I have to delete 16,000 docs, I then need to pause my code for a minute after 15,000 before processing the remaining docs due to the 15,000 operations/minute limit.
– kashiB
Nov 12 at 16:45
That delete operation limit in Search is always 15000/min no matter which environment you are using, what you can do is rather contact google to upgrade it or establish the delete job to cloud task (work independently and still have 15000 limit) and publish the data to Pub/Sub first. If second one is acceptable, I can share an example.
– MatrixTai
Nov 13 at 3:45
Sure! Would you mind sharing an example?
– kashiB
Nov 13 at 6:21
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I need to search my App Engine indexed documents using the Search API. From what I can tell, the Search API can only be referenced with the google.appengine APIs for the standard environment.
My problem is that some hydrating, flushing, and querying takes longer than 60 seconds. I need to return a response from app engine, continue processing the request in the background, then publish the results to Pub/Sub. However, I can spawn threads or use background_thread in the standard environment. I'd switch to the flexible environment, but I cannot use the Python Search API library.
Is my only option to switch to the flex environment, and use REST APIs?
google-app-engine google-cloud-platform google-search-api google-app-engine-python app-engine-flexible
I need to search my App Engine indexed documents using the Search API. From what I can tell, the Search API can only be referenced with the google.appengine APIs for the standard environment.
My problem is that some hydrating, flushing, and querying takes longer than 60 seconds. I need to return a response from app engine, continue processing the request in the background, then publish the results to Pub/Sub. However, I can spawn threads or use background_thread in the standard environment. I'd switch to the flexible environment, but I cannot use the Python Search API library.
Is my only option to switch to the flex environment, and use REST APIs?
google-app-engine google-cloud-platform google-search-api google-app-engine-python app-engine-flexible
google-app-engine google-cloud-platform google-search-api google-app-engine-python app-engine-flexible
edited Nov 12 at 22:47
asked Nov 12 at 7:16
kashiB
8419
8419
Have you tryindex.search_async()
?
– MatrixTai
Nov 12 at 7:50
I don't think that will work. Let's say I have to delete 16,000 docs, I then need to pause my code for a minute after 15,000 before processing the remaining docs due to the 15,000 operations/minute limit.
– kashiB
Nov 12 at 16:45
That delete operation limit in Search is always 15000/min no matter which environment you are using, what you can do is rather contact google to upgrade it or establish the delete job to cloud task (work independently and still have 15000 limit) and publish the data to Pub/Sub first. If second one is acceptable, I can share an example.
– MatrixTai
Nov 13 at 3:45
Sure! Would you mind sharing an example?
– kashiB
Nov 13 at 6:21
add a comment |
Have you tryindex.search_async()
?
– MatrixTai
Nov 12 at 7:50
I don't think that will work. Let's say I have to delete 16,000 docs, I then need to pause my code for a minute after 15,000 before processing the remaining docs due to the 15,000 operations/minute limit.
– kashiB
Nov 12 at 16:45
That delete operation limit in Search is always 15000/min no matter which environment you are using, what you can do is rather contact google to upgrade it or establish the delete job to cloud task (work independently and still have 15000 limit) and publish the data to Pub/Sub first. If second one is acceptable, I can share an example.
– MatrixTai
Nov 13 at 3:45
Sure! Would you mind sharing an example?
– kashiB
Nov 13 at 6:21
Have you try
index.search_async()
?– MatrixTai
Nov 12 at 7:50
Have you try
index.search_async()
?– MatrixTai
Nov 12 at 7:50
I don't think that will work. Let's say I have to delete 16,000 docs, I then need to pause my code for a minute after 15,000 before processing the remaining docs due to the 15,000 operations/minute limit.
– kashiB
Nov 12 at 16:45
I don't think that will work. Let's say I have to delete 16,000 docs, I then need to pause my code for a minute after 15,000 before processing the remaining docs due to the 15,000 operations/minute limit.
– kashiB
Nov 12 at 16:45
That delete operation limit in Search is always 15000/min no matter which environment you are using, what you can do is rather contact google to upgrade it or establish the delete job to cloud task (work independently and still have 15000 limit) and publish the data to Pub/Sub first. If second one is acceptable, I can share an example.
– MatrixTai
Nov 13 at 3:45
That delete operation limit in Search is always 15000/min no matter which environment you are using, what you can do is rather contact google to upgrade it or establish the delete job to cloud task (work independently and still have 15000 limit) and publish the data to Pub/Sub first. If second one is acceptable, I can share an example.
– MatrixTai
Nov 13 at 3:45
Sure! Would you mind sharing an example?
– kashiB
Nov 13 at 6:21
Sure! Would you mind sharing an example?
– kashiB
Nov 13 at 6:21
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
You probably want to use app engine task queue, which is a task scheduler for queuing pending tasks for another app engine to do it as App engine is single thread engine.
For example,
1. Set up a new service to handle task (OPTIONAL)
Setup a yaml call newtaskworker.yaml
which is similar to your app.yaml
, as you may want another service to do the task not the original one.
Only difference is remember to add a service name for it, service: newtaskworker
Remember to deploy it by gcloud app deploy newtaskworker.yaml
2. Set up a queue
Read How to Create new queue, generally speak you need a queue.yaml
for queuing the tasks. Remember to deploy it by gcloud app deploy queue.yaml
queue:
- name: queue_name
rate: 20/s #You may limit the speed of *START* new task here
bucket_size: 40
max_concurrent_requests: 10 #This is limited by your max_instances allowed in newtaskworker.yaml, you may simply omit it
3. Finally your code
from google.appengine.api import taskqueue
#/deleteTask
class DeleteTask(webapp2.RequestHandler):
def get(self):
paramA = self.request.get('paramA')
paramB = self.request.get('paramB')
#your Search delete here
class GetPostDataTask(webapp2.RequestHandler):
def get(self):
#If you don't want to use a new service, simply use 'default` in target.
#Your Go to Pub/Sub work here.
taskqueue.add(queue_name='queue_name', url='/deleteTask', method='GET', params='paramA': 1, 'paramB': 2, target='newtaskworker')
If nothing goes wrong, you can find your task in Console -> Tools -> Cloud Task
Wow. I think this solves my problem. I'll let you know tomorrow after I try it out. Thanks!!!
– kashiB
Nov 13 at 8:23
This worked! Thank you :)
– kashiB
Nov 15 at 0:58
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53257420%2fhow-do-i-query-gcp-search-apis-asynchronously-from-an-app-engine-instance%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
You probably want to use app engine task queue, which is a task scheduler for queuing pending tasks for another app engine to do it as App engine is single thread engine.
For example,
1. Set up a new service to handle task (OPTIONAL)
Setup a yaml call newtaskworker.yaml
which is similar to your app.yaml
, as you may want another service to do the task not the original one.
Only difference is remember to add a service name for it, service: newtaskworker
Remember to deploy it by gcloud app deploy newtaskworker.yaml
2. Set up a queue
Read How to Create new queue, generally speak you need a queue.yaml
for queuing the tasks. Remember to deploy it by gcloud app deploy queue.yaml
queue:
- name: queue_name
rate: 20/s #You may limit the speed of *START* new task here
bucket_size: 40
max_concurrent_requests: 10 #This is limited by your max_instances allowed in newtaskworker.yaml, you may simply omit it
3. Finally your code
from google.appengine.api import taskqueue
#/deleteTask
class DeleteTask(webapp2.RequestHandler):
def get(self):
paramA = self.request.get('paramA')
paramB = self.request.get('paramB')
#your Search delete here
class GetPostDataTask(webapp2.RequestHandler):
def get(self):
#If you don't want to use a new service, simply use 'default` in target.
#Your Go to Pub/Sub work here.
taskqueue.add(queue_name='queue_name', url='/deleteTask', method='GET', params='paramA': 1, 'paramB': 2, target='newtaskworker')
If nothing goes wrong, you can find your task in Console -> Tools -> Cloud Task
Wow. I think this solves my problem. I'll let you know tomorrow after I try it out. Thanks!!!
– kashiB
Nov 13 at 8:23
This worked! Thank you :)
– kashiB
Nov 15 at 0:58
add a comment |
up vote
1
down vote
accepted
You probably want to use app engine task queue, which is a task scheduler for queuing pending tasks for another app engine to do it as App engine is single thread engine.
For example,
1. Set up a new service to handle task (OPTIONAL)
Setup a yaml call newtaskworker.yaml
which is similar to your app.yaml
, as you may want another service to do the task not the original one.
Only difference is remember to add a service name for it, service: newtaskworker
Remember to deploy it by gcloud app deploy newtaskworker.yaml
2. Set up a queue
Read How to Create new queue, generally speak you need a queue.yaml
for queuing the tasks. Remember to deploy it by gcloud app deploy queue.yaml
queue:
- name: queue_name
rate: 20/s #You may limit the speed of *START* new task here
bucket_size: 40
max_concurrent_requests: 10 #This is limited by your max_instances allowed in newtaskworker.yaml, you may simply omit it
3. Finally your code
from google.appengine.api import taskqueue
#/deleteTask
class DeleteTask(webapp2.RequestHandler):
def get(self):
paramA = self.request.get('paramA')
paramB = self.request.get('paramB')
#your Search delete here
class GetPostDataTask(webapp2.RequestHandler):
def get(self):
#If you don't want to use a new service, simply use 'default` in target.
#Your Go to Pub/Sub work here.
taskqueue.add(queue_name='queue_name', url='/deleteTask', method='GET', params='paramA': 1, 'paramB': 2, target='newtaskworker')
If nothing goes wrong, you can find your task in Console -> Tools -> Cloud Task
Wow. I think this solves my problem. I'll let you know tomorrow after I try it out. Thanks!!!
– kashiB
Nov 13 at 8:23
This worked! Thank you :)
– kashiB
Nov 15 at 0:58
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
You probably want to use app engine task queue, which is a task scheduler for queuing pending tasks for another app engine to do it as App engine is single thread engine.
For example,
1. Set up a new service to handle task (OPTIONAL)
Setup a yaml call newtaskworker.yaml
which is similar to your app.yaml
, as you may want another service to do the task not the original one.
Only difference is remember to add a service name for it, service: newtaskworker
Remember to deploy it by gcloud app deploy newtaskworker.yaml
2. Set up a queue
Read How to Create new queue, generally speak you need a queue.yaml
for queuing the tasks. Remember to deploy it by gcloud app deploy queue.yaml
queue:
- name: queue_name
rate: 20/s #You may limit the speed of *START* new task here
bucket_size: 40
max_concurrent_requests: 10 #This is limited by your max_instances allowed in newtaskworker.yaml, you may simply omit it
3. Finally your code
from google.appengine.api import taskqueue
#/deleteTask
class DeleteTask(webapp2.RequestHandler):
def get(self):
paramA = self.request.get('paramA')
paramB = self.request.get('paramB')
#your Search delete here
class GetPostDataTask(webapp2.RequestHandler):
def get(self):
#If you don't want to use a new service, simply use 'default` in target.
#Your Go to Pub/Sub work here.
taskqueue.add(queue_name='queue_name', url='/deleteTask', method='GET', params='paramA': 1, 'paramB': 2, target='newtaskworker')
If nothing goes wrong, you can find your task in Console -> Tools -> Cloud Task
You probably want to use app engine task queue, which is a task scheduler for queuing pending tasks for another app engine to do it as App engine is single thread engine.
For example,
1. Set up a new service to handle task (OPTIONAL)
Setup a yaml call newtaskworker.yaml
which is similar to your app.yaml
, as you may want another service to do the task not the original one.
Only difference is remember to add a service name for it, service: newtaskworker
Remember to deploy it by gcloud app deploy newtaskworker.yaml
2. Set up a queue
Read How to Create new queue, generally speak you need a queue.yaml
for queuing the tasks. Remember to deploy it by gcloud app deploy queue.yaml
queue:
- name: queue_name
rate: 20/s #You may limit the speed of *START* new task here
bucket_size: 40
max_concurrent_requests: 10 #This is limited by your max_instances allowed in newtaskworker.yaml, you may simply omit it
3. Finally your code
from google.appengine.api import taskqueue
#/deleteTask
class DeleteTask(webapp2.RequestHandler):
def get(self):
paramA = self.request.get('paramA')
paramB = self.request.get('paramB')
#your Search delete here
class GetPostDataTask(webapp2.RequestHandler):
def get(self):
#If you don't want to use a new service, simply use 'default` in target.
#Your Go to Pub/Sub work here.
taskqueue.add(queue_name='queue_name', url='/deleteTask', method='GET', params='paramA': 1, 'paramB': 2, target='newtaskworker')
If nothing goes wrong, you can find your task in Console -> Tools -> Cloud Task
edited Nov 14 at 1:25
answered Nov 13 at 8:11
MatrixTai
1,921421
1,921421
Wow. I think this solves my problem. I'll let you know tomorrow after I try it out. Thanks!!!
– kashiB
Nov 13 at 8:23
This worked! Thank you :)
– kashiB
Nov 15 at 0:58
add a comment |
Wow. I think this solves my problem. I'll let you know tomorrow after I try it out. Thanks!!!
– kashiB
Nov 13 at 8:23
This worked! Thank you :)
– kashiB
Nov 15 at 0:58
Wow. I think this solves my problem. I'll let you know tomorrow after I try it out. Thanks!!!
– kashiB
Nov 13 at 8:23
Wow. I think this solves my problem. I'll let you know tomorrow after I try it out. Thanks!!!
– kashiB
Nov 13 at 8:23
This worked! Thank you :)
– kashiB
Nov 15 at 0:58
This worked! Thank you :)
– kashiB
Nov 15 at 0:58
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53257420%2fhow-do-i-query-gcp-search-apis-asynchronously-from-an-app-engine-instance%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Have you try
index.search_async()
?– MatrixTai
Nov 12 at 7:50
I don't think that will work. Let's say I have to delete 16,000 docs, I then need to pause my code for a minute after 15,000 before processing the remaining docs due to the 15,000 operations/minute limit.
– kashiB
Nov 12 at 16:45
That delete operation limit in Search is always 15000/min no matter which environment you are using, what you can do is rather contact google to upgrade it or establish the delete job to cloud task (work independently and still have 15000 limit) and publish the data to Pub/Sub first. If second one is acceptable, I can share an example.
– MatrixTai
Nov 13 at 3:45
Sure! Would you mind sharing an example?
– kashiB
Nov 13 at 6:21