0

Suppose I have basic User model in ndb with following properties:

```

name = ndb.StringProperty(default='')
username = ndb.StringProperty(required=True)
email = ndb.StringProperty(default='')
active = ndb.BooleanProperty(default=True)
admin = ndb.BooleanProperty(default=False)
permissions = ndb.StringProperty(repeated=True)
verified = ndb.BooleanProperty(default=False)
token = ndb.StringProperty(default='')
password_hash = ndb.StringProperty(default='')
bio = ndb.StringProperty(default='')
location = ndb.StringProperty(default='')
facebook = ndb.StringProperty(default='')
twitter = ndb.StringProperty(default='')
gplus = ndb.StringProperty(default='')
github = ndb.StringProperty(default='')

```

Let's say I want to perform LIKE query on fields name username bio

I've read this answer about NDB and Search API and I'm not clear whether whether I should only store name username bio via Search API and rest in NDB and manually maintain their consistency, or should I store all properties via Search API, so retrieving data can be faster/simpler.

Thanks for any kind of suggestions :)

Community
  • 1
  • 1
ma2s
  • 1,312
  • 1
  • 11
  • 24
  • The way Stack Overflow works, this isn't really the kind of place for such a question. I think groups.google.com/forum/#!forum/google-appengine could be better, considering it has the forum format closer to what you need ^^ – Patrice Mar 10 '15 at 20:05
  • the forum is gone, it moved here to SO apparently (not sure though) – EsseTi Mar 13 '15 at 11:18

2 Answers2

3

You should store any important data in Datastore. It has redundancy and resiliency - it is your "MASTER".

You should then pass off data to Search for... wait for it... searching! That might include the ID of your Datastore record.

You could then retrieve your full data object from Memcache or Datastore via batch gets if you need more fields than are present in the Search document.

Tom
  • 1,563
  • 12
  • 12
0

I have never seen any consistency commitment regarding the Full Text Search API (i.e. strong vs eventual consistency), it also cannot participate in transactions.

This means that while its useful for running a like query on, you need to rely on some other storage mechanism as your primary data source.

So save to the datastore, index interesting fields into the search index. When querying, search in the search index then use the id/key from the result to look up data from the datastore (ensuring any consistency constraints are met).

Nick
  • 1,822
  • 10
  • 9