Search code examples
pythongoogle-app-enginegoogle-search-api

How to implement the Search API on my GAE datastore?


I built a database that I would like to be able to search using the Search API in GAE. I clicked through the tutorials that Google has on the API, but the one thing I'm missing is how to actually turn a datastore kind into a "document". Is there a good tutorial for that somewhere? Thank you


Solution

  • You can not convert db.Model ndb.Model to search.Document.

    Why? because it does not have too much value.

    I give you some example - you have string 'this-is-black-tag' in db.StringProperty() how to convert it:

    1. you can use it as Atoms - so match will be if exact match
    2. you can use it as String - so it will be broken into 'this', 'is', 'black', 'tag' than tokenized 't', 'th', 'thi', 'this', ...
    3. you can decide that is not visible since not help in search but give false hits

    You need design search feature yourself that it should be manual design that is answer.

    You just need:

    1. create search.Document
    2. add fields
    3. add document to index

    Read reference: https://developers.google.com/appengine/docs/python/search/documentclass