Python Search API does not allow specifying Ancestors while creating a Document for an Index

30 views
Skip to first unread message

Naveed

unread,
Jul 3, 2014, 12:40:01 PM7/3/14
to google-a...@googlegroups.com
Search API: How do I specify the ancestor for a document when adding to an index. The index in index.yaml looks like this:

- kind: abc
  ancestor
: yes
  properties
:
 
- name: date_time
    direction
: desc


Currently, this is how I add a document to an index:

from google.appengine.api import search
fields = []
d = search.Document(fields = fields,doc_id=some_id)
index = search.Index(name='abc').put(d)


As you can see, I can specify the fields and the doc_id, but not the ancestor. 
Perhaps I have not understood how this works very well.

I do understand that there is a workaround where I can add the ancestor key as a prefix in the doc_id. But I would like to know FIRST if there is an option already to specify an ancestor

Vinny P

unread,
Jul 13, 2014, 12:41:10 AM7/13/14
to google-a...@googlegroups.com
On Thu, Jul 3, 2014 at 11:40 AM, Naveed <00.n...@gmail.com> wrote:
I do understand that there is a workaround where I can add the ancestor key as a prefix in the doc_id. But I would like to know FIRST if there is an option already to specify an ancestor


No, there isn't an option. 

If you need to query by an ancestor key, you can supply the key as another document field during document creation.

   
-----------------
-Vinny P
Technology & Media Consultant
Chicago, IL

App Engine Code Samples: http://www.learntogoogleit.com

Reply all
Reply to author
Forward
0 new messages