在this repo中,联系人搜索似乎可以按名字和姓氏进行操作。
const queryParts = query.split(/ /);
const queryFirst = queryParts.length == 2 ? queryParts[0] : query;
const queryLast = queryParts.length == 2 ? queryParts[1] : query;
const queryOp = queryParts.length == 2 ? "AND" : "OR";
const match = `{contacts:FirstName}:${queryFirst}* ${queryOp} {contacts:LastName}:${queryLast}*`;
querySpec = smartstore.buildMatchQuerySpec(null, match, "ascending", 100, "LastName");
因此,我将其更改为:
const match = `{contacts:MobilePhone}:${query}`;
querySpec = smartstore.buildMatchQuerySpec(null, match, 'ascending', 1);
有错误:
Error->"com.salesforce.androidsdk.smartstore.store.SmartSqlHelper$SmartSqlException: contacts does not have an index on MobilePhone at character 127"
与HomePhone相同的错误。是否可以通过电话号码搜索联系人?