3

In this Firebase App Indexing sample code for stickers and sticker packs there seem to be two different methods to associate a "Sticker" with a "StickerPack".

In method 1, you create a StickerPack and then associate the stickers with it by calling put using a key named "hasSticker":

Method #1

new Indexable.Builder("StickerPack")
   .setName("Snoopy Pack")
   .setImage("content://sticker/pack/canonical/image")
   // see: Support links to your app content section
   .setUrl("http://sticker/pack/canonical/url/snoopy")
   // Set the accessibility label for the sticker pack.
   .setDescription("A sticker pack of Snoopy")
   .put("hasSticker",
        new Indexable.Builder("Sticker")
          .setName("Hey")
          .setImage("http://link/to/the/image/hey")
          .setDescription("A Snoopy hey sticker.")
          .build(),
       new Indexable.Builder("Sticker")
          .setName("Bye")
          .setImage("http://link/to/the/image/bye")
          .setDescription("A Snoopy bye sticker.")
          .build())
   .build());

In method 2, you create a Sticker and then associate the StickerPack with it by calling put using a key named "isPartOf":

Method #2

new Indexable.Builder("Sticker")
   .setName("Hey")
   .setImage("http://www.snoopysticker.com?id=1234")
   // see: Support links to your app content section
   .setUrl("http://sticker/canonical/image/hey")
   // Set the accessibility label for the sticker.
   .setDescription("A sticker for hi")
   // Add search keywords.
   .put("keywords", "hey", "snoopy", "hi", "hello")
   .put("isPartOf",
        new Indexable.Builder("StickerPack")
          .setName("Snoopy Pack"))
          .build())
   .build()),

To muddy the waters, in this official google firebase quickstart for app-indexing on github they go to some trouble use both the hasSticker and isPartOf methods. And to make it more interesting, "isPartOf" has changed its name to just "partOf":

indexableStickerBuilder.put("keywords", "tag1_" + i, "tag2_" + i)
    // StickerPack object that the sticker is part of.
    .put("partOf", new Indexable.Builder("StickerPack")
        .setName(CONTENT_PROVIDER_STICKER_PACK_NAME)
        .build());

Is there any benefit to using both "hasSticker" and "isPartOf" when defining a Sticker and its relationship to a StickerPack -- or is just one of them good enough?

And which is correct: "partOf" or "isPartOf" -- or are both correct?

albert c braun
  • 2,650
  • 1
  • 22
  • 32

0 Answers0