python - Bulk uploading "search api" documents to appengine? -
python - Bulk uploading "search api" documents to appengine? -
we upload 30k entities datastore in 1 go, while creating documents strings associated these entities.
this allow partial search on strings datastore not suited for.
however, haven't been able find resources or documentation on how mass upload documents using search api functionality.
how go this?
we tried using bulkloader, keeps giving next error
google.appengine.ext.db.kinderror: no implementation kind 'prototype'    this because trying upload ndb models, error suggest defaulting db
we tried hack our way around , define class db model , upload it. works, , info uploaded datastore, post_put_hook doesn't work
here's code:
#models.py  import datetime google.appengine.ext import db google.appengine.tools import bulkloader   class prototypee(db.model):     #creating db model of   info     p_id=db.stringproperty(indexed=true,required=true)     p_name=db.stringproperty(required=true)     p_val=db.integerproperty(required=true)     p_lnk=db.stringproperty(required=true)     p_src=db.stringproperty(choices=site_list)     p_create_time=db.datetimeproperty(auto_now_add=true)     p_update_time=db.datetimeproperty(auto_now=true)     p_gen=db.stringproperty(choices=gen_list)     p_img=db.stringproperty()     p_cat=db.stringproperty()     p_brd=db.stringproperty()     p_keys=db.stringproperty()       def _post_put_hook(self,future):         doc_key=future.get_result()         doc_id=doc_key.id()         doc= search.document(doc_id=unicode(doc_id),         fields=[         search.textfield(name="keywords",value=self.p_keys),         search.numberfield(name="value",value=self.p_price)         ])  #document         logging.info(doc)         try:             index=search.index(name="store_doc")             index.put(doc)      #putting   info document         except search.error:             logging.exception('doc  set failed')    and loader:
#proto_loader.py  import datetime google.appengine.ext import ndb google.appengine.tools import bulkloader import models    class protoloader(bulkloader.loader):     def __init__(self):     bulkloader.loader.__init__(self, 'prototypee',        [('p_id', str),     ('p_name', str),     ('p_val', int),     ('p_lnk', str),     ('p_src',str),     ('p_gen',str),     ('p_img',str),     ('p_cat',str),     ('p_brd',str),     ('p_keys',str)     ])  loaders = [protoloader]    this succeeds in uploading info datastore, hook not called , no documents created.
do need edit bulkloader file around issue?
update: mentioned earlier, reason attempted mixing ndb , db next error when defining class ndb.model through
traceback (most recent  phone call last):   file "appcfg.py", line 126, in <module>     run_file(__file__, globals())   file "appcfg.py", line 122, in run_file     execfile(_paths.script_file(script_name), globals_)   file "/home/stw/google/google_appengine/google/appengine/tools/appcfg.py", line 5220, in <module>     main(sys.argv)   file "/home/stw/google/google_appengine/google/appengine/tools/appcfg.py", line 5211, in main     result = appcfgapp(argv).run()   file "/home/stw/google/google_appengine/google/appengine/tools/appcfg.py", line 2886, in run     self.action(self)   file "/home/stw/google/google_appengine/google/appengine/tools/appcfg.py", line 4890, in __call__      homecoming method()   file "/home/stw/google/google_appengine/google/appengine/tools/appcfg.py", line 4693, in performupload     run_fn(args)   file "/home/stw/google/google_appengine/google/appengine/tools/appcfg.py", line 4574, in runbulkloader     sys.exit(bulkloader.run(arg_dict))   file "/home/stw/google/google_appengine/google/appengine/tools/bulkloader.py", line 4408, in run      homecoming _performbulkload(arg_dict)   file "/home/stw/google/google_appengine/google/appengine/tools/bulkloader.py", line 4219, in _performbulkload     loadconfig(config_file)   file "/home/stw/google/google_appengine/google/appengine/tools/bulkloader.py", line 3886, in loadconfig     loader.registerloader(cls())   file "proto_loader.py", line 40, in __init__     ('p_keys',str)   file "/home/stw/google/google_appengine/google/appengine/tools/bulkloader.py", line 2687, in __init__     getimplementationclass(kind)   file "/home/stw/google/google_appengine/google/appengine/tools/bulkloader.py", line 957, in getimplementationclass     implementation_class = db.class_for_kind(kind_or_class_key)   file "/home/stw/google/google_appengine/google/appengine/ext/db/__init__.py", line 296, in class_for_kind     raise kinderror('no implementation kind \'%s\'' % kind) google.appengine.ext.db.kinderror: no implementation kind 'prototypee'    as error indicates, bulkloader assumes db class , checks db.class_for_kind results in error when using ndb
 python google-app-engine full-text-search app-engine-ndb bulkloader 
 
Comments
Post a Comment