Whenever I've tried doing a SearchableModelDescendant.all
(keys_only=True).search(query) construction, it has failed saying it
doesn't understand the keys_only parameter - see 'Using __key__ and
SearchableModel 
http://groups.google.com/group/google-appengine/browse_thread/thread/73dc1dc31bfd497b

Do you know if this was fixed in a recent release?

Adrian


On Jun 23, 11:33 am, "Nick Johnson (Google)" <nick.john...@google.com>
wrote:
> 2009/6/23 Ian Lewis <ianmle...@gmail.com>
>
> > ogterran,
>
> > It should do one for the search and then one for each item in the search
> > result.
>
> Not quite - it will do one _query_, and multiple gets. A get is much, much
> cheaper than a query. You're right about the number of round-trips, though.
>
> > If you are worried performance on the calls to the datastore you can modify
> > this code to make the ProductSearchIndex entity be a child of the Product
> > entity and  use a key only query to retrieve only the keys for the search
> > index entities (since we only really care about the Products anyway).
>
> Good idea!
>
>
>
>
>
> > This will still to the same number of queries but will avoid the overhead
> > of deserializing the ProductSearchIndex objects (and the associated index
> > list property which might be long).
>
> > Something like the following should work:
>
> > class Product(db.Model):
> >        pid = db.StringProperty(required=True)
> >        title = db.StringProperty(required=True)
> >        site = db.StringProperty(required=True)
> >        url = db.LinkProperty(required=True)
>
> > class ProductSearchIndex(search.SearchableModel):
> >        # parent == Product
> >        title = db.StringProperty(required=True)
>
> > ...
> > # where you write the Product
> > product = Product(pid = pid, title=title, site=site, url=url)
> > product.put()
> > index = ProductSearchIndex(parent=product, title=title)
> > index.put()
>
> > ...
> > # where you search
> > keys = ProductSearchIndex.all(keys_only=True).search(query).fetch(100)
> > for key in keys:
> >     product = Product.get(key.parent())
> >     print product.url
>
> This can be done much more efficiently:
>   keys = ProductSearchIndex.all(keys_only=True).search(query).fetch(100)
>   products = db.get(x.parent() for x in keys)
>
> Now you're down to just two round-trips!
>
> -Nick Johnson
>
>
>
>
>
> > On Tue, Jun 23, 2009 at 5:59 PM, ogterran <jonathanh...@gmail.com> wrote:
>
> >> Hi Ian,
>
> >> Thanks for the response.
> >> I have one question on number of datastore calls.
> >> How many datastore calls is the query below making?
> >> Is it 1 or 100?
>
> >> > class Product(db.Model):
> >> >        pid = db.StringProperty(required=True)
> >> >        title = db.StringProperty(required=True)
> >> >        site = db.StringProperty(required=True)
> >> >        url = db.LinkProperty(required=True)
>
> >> > class ProductSearchIndex(search.SearchableModel):
> >> >        product = db.ReferenceProperty(Product)
> >> >        title = db.StringProperty(required=True)
>
> >> query = ProductSearchIndex.all().search(searchtext)
> >> results = query.fetch(100)
> >> for i, v in enumerate(results):
> >>        print v.product.url
>
> >> Thanks
> >> Jon
>
> > --
> > =======================================
> > 株式会社ビープラウド  イアン・ルイス
> > 〒150-0012
> > 東京都渋谷区広尾1-11-2アイオス広尾ビル604
> > email: ianmle...@beproud.jp
> > TEL:03-5795-2707
> > FAX:03-5795-2708
> >http://www.beproud.jp/
> > =======================================
>
> --
> Nick Johnson, App Engine Developer Programs Engineer
> Google Ireland Ltd. :: Registered in Dublin, Ireland, Registration Number:
> 368047
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to