Pergunta

I'm trying to understand the concept of Documents on Google App Engine's Search API. The concept I'm having trouble with is the idea behind storing documents. So for example, say in my database I have this:

class Business(ndb.Model):
   name = ndb...
   description = ndb...

For each business, I am storing a document so I can do full-text searches on the name and description. My questions are:

  1. Is this right? Does these mean we are essentially storing each entity TWICE, in two different places, just to make it searchable?

  2. If the answer to above is yes, is there a better way to do it?

  3. And again if the answer to number 1 is yes, where do the documents get stored? To the high-rep DS?

I just want to make sure I am thinking about this concept correctly. Storing entities in docs means I have to maintain each entity in two separate places... doesn't seem very optimal just to keep it searchable.

Foi útil?

Solução

You have it worked out already.

Full Text Search Overview

The Search API allows your application to perform Google-like searches over structured data. You can search across several different types of data (plain text, HTML, atom, numbers, dates, and geographic locations). Searches return a sorted list of matching text. You can customize the sorting and presentation of results.

As you don't get to search "inside" the contents of the models in the datastore the search API provides the ability to do that for text and html.

So to link a searchable text document (e.g a product description) to a model in the datastore (e.g. that product's price) you have to "manually" make that link between the documents and the data-store objects they relate to. You can use the search api and the datastore totally independently of each other also so you have to build that in. AFAIK there is no automatic linkage between them.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top