通过应用程序索引我向GBoard添加了贴纸包,但GBoard搜索无法通过关键字找到我的贴纸。
new Indexable.Builder("Sticker")
.setName("Bye")
.setImage("http://www.snoopysticker.com?id=1234")
.setUrl("http://sticker/canonical/image/bye")
.setDescription("A sticker for Bye")
.put("keywords", "bye", "snoopy", "see ya", "good bye")
.put("isPartOf",
new Indexable.Builder("StickerPack")
.setName("Snoopy Pack")
.build())
.build())};
答案 0 :(得分:1)
问题出现在代码的另一部分,因为您在上面发布的内容在下面的Google's sample project for stickers改编的示例中效果很好:
public static void clearStickers(FirebaseAppIndex firebaseAppIndex) {
Task<Void> task = firebaseAppIndex.removeAll();
task.addOnSuccessListener(__ -> Log.i(TAG, SUCCESS_IN_CLEARING_STICKERS));
task.addOnFailureListener(e -> Log.i(TAG, FAILED_TO_CLEAR_STICKERS, e));
}
public static void setStickers(final Context context, FirebaseAppIndex firebaseAppIndex) {
try {
List<Indexable> stickers = getIndexableStickers(context);
Indexable stickerPack = getIndexableStickerPack(context);
List<Indexable> indexables = new ArrayList<>(stickers);
indexables.add(stickerPack);
Task<Void> task = firebaseAppIndex.update(
indexables.toArray(new Indexable[indexables.size()]));
task.addOnSuccessListener(__ -> Log.i(TAG, SUCCESS_IN_INSTALLING_STICKERS));
task.addOnFailureListener(e -> Log.i(TAG, FAILED_TO_INSTALL_STICKERS, e));
} catch (IOException | FirebaseAppIndexingInvalidArgumentException e) {
Log.e(TAG, ERROR_IN_SETTING_STICKERS, e);
}
}
private static Indexable getIndexableStickerPack(final Context context)
throws IOException, FirebaseAppIndexingInvalidArgumentException {
List<Indexable> indexables = StreamSupport
.stream(getStickerBuilders(context))
.map(IndexableBuilder::build)
.collect(Collectors.toList());
StickerPackBuilder stickerPackBuilder = Indexables.stickerPackBuilder()
.setName(STICKER_PACK_NAME)
// Use the first sticker as the hero for the pack
.setUrl(String.format(STICKER_PACK_URL_PATTERN, 0))
// Defaults to the first sticker in "hasSticker". Used to select between sticker
// packs so should be representative of the sticker pack.
.setImage(StickersDataFactory.getAllStickerReference().get(0).getURL())
.put("hasSticker", indexables.toArray(new Indexable[indexables.size()]))
.setDescription(STICKER_PACK_NAME);
return stickerPackBuilder.build();
}
private static List<Indexable> getIndexableStickers(final Context context)
throws IOException, FirebaseAppIndexingInvalidArgumentException {
List<Indexable> indexableStickers = new ArrayList<>();
List<Indexable.Builder> stickerBuilders = getStickerBuilders(context);
for (Indexable.Builder stickerBuilder : stickerBuilders) {
stickerBuilder.put("keywords", getKeywordsForSticker(context, null))
.put("isPartOf", new Indexable.Builder("StickerPack").setName(STICKER_PACK_NAME) .build());
indexableStickers.add(stickerBuilder.build());
}
return indexableStickers;
}
private static List<Indexable.Builder> getStickerBuilders(final Context context)
throws IOException, FirebaseAppIndexingInvalidArgumentException {
List<Indexable.Builder> stickerBuilders = new ArrayList<>();
// Start from 1 because the first sticker will be used as hero for the pack
for (int i = 1; i < StickersDataFactory.getAllStickerReference().size(); i++) {
stickerBuilders.add(new Indexable.Builder("Sticker")
.setName(StickersDataFactory.getAllStickerReference().get(i).getName())
.setUrl(String.format(STICKER_URL_PATTERN, i))
.setImage(StickersDataFactory.getAllStickerReference().get(i).getURL())
.setDescription("Random description")
.put("keywords", getKeywordsForSticker(context, StickersDataFactory.getAllStickerReference().get(i)))
.put("isPartOf", new Indexable.Builder("StickerPack").setName(STICKER_PACK_NAME) .build()));
}
return stickerBuilders;
}
答案 1 :(得分:0)
而不是SELECT
T.sku,
SUM(T.stockQty) as totle,
IFNULL(A.`store1`,0) AS `store1`,
IFNULL(B.`store2`,0) AS `store2`
FROM `stockList` AS T
LEFT JOIN
(
SELECT sku,SUM(`stockQty`) as `store1`
FROM `stockList`
WHERE `idStock`=1
GROUP BY sku
) as A ON A.sku = T.sku
LEFT JOIN
(
SELECT sku,SUM(`stockQty`) as `store2`
FROM `stockList`
WHERE `idStock`=2
GROUP BY sku
) AS B ON T.sku =B.sku
GROUP BY T.sku
它应该是new Indexable.Builder("Sticker")
。我从这个官方Google example获取此信息。