Domanda

To create a Document in appengine, I can do this

Document document = Document.newBuilder().setId("document id")
   .setLocale(Locale.UK)
   .addField(Field.newBuilder()
       .setName("subject")
       .setText("going for dinner"))
   .addField(Field.newBuilder()
       .setName("body")
       .setHTML("<html>I found a restaurant.</html>"))
   .addField(Field.newBuilder()
       .setName("signature")
       .setText("ten post jest przeznaczony dla odbiorcy")
       .setLocale(new Locale("pl")))
   .addField(Field.newBuilder()
       .setName("tag")
       .setText("food"))
   .addField(Field.newBuilder()
       .setName("tag")
       .setText("friend"))
   .build();

May I set one of the addField values to a Document?

I need the following setup

Book author price review review review // many, many Reviews

Review user rating comment

How might I create this compound document, as it were, for the app-engine Search API?

È stato utile?

Soluzione

You can't have compound documents like that in a single app engine search index. However, there are other things you can do:

  1. A document can have multiple fields with the same name. That is, you could add a field named "review" multiple times, each time with different contents.
  2. You can create separate indexes, one for book data that contains book documents, and one for review data that contains review documents.

It really depends on what your search usage patterns are going to be.

Altri suggerimenti

You could create separate indexes, as follows:

  • Books
  • Reviews

In the Reviews index, you could also have the book id and use that to look up the Reviews for the particular book.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top