如何将链接实体中的字段包含到全文实体索引中?

How to include field from a linked entity into Full-Text Entity Index?

我已将 Customer Location 添加到全文实体索引中,但无法弄清楚如何从中获取 Address Line 1位置将成为全文索引的一部分并显示在结果中。

要包含链接实体的字段(那些在数据输入屏幕上与 top-level 实体 有 one-to-one 关系的实体),需要指定 top-level 实体字段应与 PXSelectorAttribute 一起使用以检索链接的实体。在 top-level 实体字段作为链接实体之间的桥梁之后,您将指定辅助实体的字段,这些字段应包含在 Full-Text 索引中 and/or 显示在结果中.请记住,只有 top-level 个装饰有 PXSelectorAttribute 或 PXDimensionSelectorAttribute 的实体字段能够充当链接实体之间的桥梁。

例如,要将来自 Address DAC 的字段包含到 Customer Location Full-Text 实体索引中,您必须添加DefAddressID 来自 Location DAC 的字段,然后列出来自 Address DAC 的字段:

public partial class Location : PX.Data.IBqlTable, IPaymentTypeDetailMaster, ILocation
{
    ...
    public abstract class defAddressID : IBqlField { }
    [PXDBInt()]
    [PXDBChildIdentity(typeof(Address.addressID))]
    [PXUIField(DisplayName = "Default Address", Visibility = PXUIVisibility.Invisible)]
    [PXSelector(typeof(Search<Address.addressID>), DirtyRead = true)]
    public virtual int? DefAddressID { get; set; }
    ...
}

以下代码片段中的 CustomerLocation DAC 可以作为自定义 DAC 的完美示例,用于将 CustomerLocation 添加到Full-Text 实体索引:

[Serializable]
[PXCacheName("Customer Location")]
[PXBreakInheritance]
public partial class CustomerLocation : SelectedCustomerLocation
{
    public new abstract class bAccountID : IBqlField { }

    [Customer(typeof(Search<Customer.bAccountID,
        Where<Customer.type, Equal<BAccountType.customerType>,
            Or<Customer.type, Equal<BAccountType.prospectType>,
            Or<Customer.type, Equal<BAccountType.combinedType>>>>>),
        IsKey = true)]
    public override int? BAccountID { get; set; }

    public new abstract class locationCD : IBqlField { }

    public new abstract class descr : IBqlField { }

    public new abstract class defAddressID : IBqlField { }

    public new abstract class locType : IBqlField { }

    public new abstract class noteID : IBqlField { }

    [PXNote()]
    [PXSearchable(SM.SearchCategory.CR, "{1} {2}: {3}",
        new Type[] {
            typeof(CustomerLocation.bAccountID),
            typeof(Customer.acctCD),
            typeof(CustomerLocation.locationCD),
            typeof(CustomerLocation.descr) },
        new Type[] {
            typeof(CustomerLocation.bAccountID),
            typeof(Customer.acctCD),
            typeof(CustomerLocation.locationCD),
            typeof(CustomerLocation.descr),
            typeof(CustomerLocation.defAddressID),
            typeof(Address.addressLine1),
            typeof(Address.addressLine2),
            typeof(Address.city),
            typeof(Address.countryID) },
        Line1Format = "{0} {2}",
        Line1Fields = new Type[] {
            typeof(CustomerLocation.descr),
            typeof(CustomerLocation.defAddressID),
            typeof(Address.addressLine1) },
        Line2Format = "{1}",
        Line2Fields = new Type[] {
            typeof(CustomerLocation.defAddressID),
            typeof(Address.addressLine2) },
        WhereConstraint = 
            typeof(Where<CustomerLocation.locType, Equal<LocTypeList.customerLoc>,
                Or<CustomerLocation.locType, Equal<LocTypeList.combinedLoc>>>),
        MatchWithJoin = typeof(InnerJoin<Customer, 
            On<Customer.bAccountID, Equal<CustomerLocation.bAccountID>>>),
        SelectForFastIndexing = typeof(Select2<CustomerLocation, 
            InnerJoin<Customer, 
                On<CustomerLocation.bAccountID, Equal<Customer.bAccountID>>>>)
    )]
    public override Guid? NoteID { get; set; }
}

确定 DefAddressID 字段,用于包含从 Address DAC 到 Full-Text 实体索引的字段, CustomerLocation 还利用附加到 BAccountID 字段的 CustomerAttribute 来包含客户的自然 application-wise AcctCD 键而不是代理 DB-level BAccountID 键。最后要提到的是 PXBreakInheritanceAttribute 需要防止在 Rebuild Full-Text Entity Index 屏幕上初始化对应于基本 DAC 的 PXCache 对象系统生成 Full-Text 实体索引要使用的实体列表。