如何将链接实体中的字段包括到全文实体索引中? [英] How to include field from a linked entity into Full-Text Entity Index?

查看:82
本文介绍了如何将链接实体中的字段包括到全文实体索引中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将客户位置添加到了全文实体索引中,但是无法弄清楚如何从位置中获取地址行1 成为全文的一部分-Text索引并显示在结果中。

I've added Customer Location to the Full-Text Entity Index, but cannot figure out how to get Address Line 1 from the Location to be part of the Full-Text Index and be displayed in the result.

推荐答案

要包括链接实体的字段(在一个(在数据输入屏幕上与顶级实体建立一对一的关系),则需要指定应使用哪个顶级实体字段以及PXSelectorAttribute来检索链接的实体。在顶级实体字段充当链接的实体之间的桥梁之后,您将指定辅助实体的字段,该字段应包含在全文索引中和/或显示在结果中。请记住,只有用PXSelectorAttribute或PXDimensionSelectorAttribute装饰的顶级实体字段才可以充当链接的实体之间的桥梁。

To includes fields of linked entities (those which are in one-to-one relationship with the top-level entity on a data entry screen), it's required to specify what top-level entity field should be used along with the PXSelectorAttribute to retrieve the linked entity. Right after the top-level entity field acting as a bridge between the linked entities, you will specify fields of the secondary entity, which should be included into the Full-Text Index and/or be displayed in the result. Keep in mind, that only top-level entity fields decorated with PXSelectorAttribute or PXDimensionSelectorAttribute have the ability to act as a bridge between the linked entities.

例如,包含字段从地址 DAC到客户位置全文实体索引中,您必须从位置中添加 DefAddressID 字段> DAC,然后从 Address DAC列出字段:

For example, to include fields from the Address DAC into the Customer Location Full-Text Entity Index, you must add the DefAddressID field from the Location DAC before listing fields from the 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的完美示例,该自定义DAC用于向全文实体索引添加客户位置

The CustomerLocation DAC found in the following code snippet can serve as a perfect example of a custom DAC used to add Customer Location to the Full-Text Entity Index:

[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 字段为了包含从地址 DAC到全文本实体索引的字段, CustomerLocation (客户位置)还利用附加到 BAccountID CustomerAttribute >字段,以包含客户的自然应用程序型 AcctCD 键,而不是代理数据库级的 BAccountID 键。最后要提及的是 PXBreakInheritanceAttribute ,当在重建全文本实体索引屏幕上系统生成要使用的实体列表时,可防止初始化与基本DAC对应的PXCache对象通过全文实体索引。

Becides the DefAddressID field, which is used to include fields from the Address DAC to the Full-Text Entity Index, CustomerLocation also utilize CustomerAttribute attached to the BAccountID field to include Customer's natural application-wise AcctCD keys instead of the surrogate DB-level BAccountID keys. Last thing to mention is the PXBreakInheritanceAttribute required to prevent initialization of PXCache objects corresponding to base DACs when on Rebuild Full-Text Entity Index screen the system generates list of entities to be used by Full-Text Entity Index.

这篇关于如何将链接实体中的字段包括到全文实体索引中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆