【问题标题】:How to include field from a linked entity into Full-Text Entity Index?如何将链接实体中的字段包含到全文实体索引中?
【发布时间】:2018-02-17 03:14:50
【问题描述】:

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

【问题讨论】:

    标签: acumatica acumatica-kb


    【解决方案1】:

    要包含链接实体的字段(在数据输入屏幕上与顶级实体一对一关系),需要指定顶级实体字段应该与 PXSelectorAttribute 一起使用来检索链接的实体。在充当链接实体之间桥梁的顶级实体字段之后,您将指定二级实体的字段,这些字段应包含在全文索引中和/或显示在结果中。请记住,只有用 PXSelectorAttribute 或 PXDimensionSelectorAttribute 修饰的顶级实体字段才能充当链接实体之间的桥梁。

    例如,要将 Address DAC 中的字段包含到 Customer Location 全文实体索引中,您必须添加 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; }
        ...
    }
    

    在以下代码 sn-p 中找到的 CustomerLocation DAC 可以作为用于将 Customer Location 添加到全文实体索引的自定义 DAC 的完美示例:

    [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; }
    }
    

    除了用于包含从 Address DAC 到全文实体索引的字段的 DefAddressID 字段之外,CustomerLocation 还利用CustomerAttribute 附加到 BAccountID 字段以包含客户的自然应用程序 AcctCD 键,而不是代理数据库级 BAccountID 键。最后要提到的是 PXBreakInheritanceAttributeRebuild Full-Text Entity Index 屏幕上系统生成要使用的实体列表时防止初始化与基本 DAC 对应的 PXCache 对象所需的按全文实体索引。

    【讨论】:

    • PXBreakInheritance 的目的是什么?还有一个问题,为什么不使用 PXCacheExtension 而是使用部分类?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多