Kernel::System::DocumentSearch::BaseDriver

NAME

Kernel::System::DocumentSearch::BaseDriver – Base class for index drivers.

PUBLIC INTERFACE

Provides methods and attributes to store and provide index related information.

has IndexName

Attribute that holds the index name to be used on the cluster.

has DocumentType

Attribute that holds the document type, that is used to identify the driver and index.

has DocumentTypeLabel

Attribute that holds the human readable label of the DocumentType.

has DocumentIDName

Attribute that holds the name of the DocumentID, to identify what real field is used as the identifier.

has DocumentTitle

Attribute that holds the field name of the title field to be implicitly included in search results.

has AgentAccess

Attribute that defines if the document type is accessible by agent search queries.

has CustomerAccess

Attribute that defines if the document type is accessible by customer search queries.

has PublicAccess

Attribute that defines if the document type is accessible by public search queries.

has MergeInto

Attribute that defines if the document is merged into other.

has VirtualDriver

Attribute that defines if the driver is real: had its own index or if its virtual: only used to group and combine results from other real drivers.

has PredefinedFiltersLookupMap

Attribute that holds the value mapping for the PredefinedFiltersLookup.

has CustomDrivers

Attribute that holds the custom index driver objects. The index driver modules are located below Kernel::System::DocumentSearch::CustomDriver::*, please refer to the single modules for more information.

BUILD()

During the instantiation of the object, it will be checked, if a configuration option DocumentSearch::IndexPrefix is available, that is used to add an index prefix to every index name. This provides the possibility to use multiple OTRS instances with the same Elasticsearch cluster.

IndexSettings()

This method provides the index settings to be used for the related index. At first it searches for related settings inside the configuration, based on the DocumentType and uses the driver internal settings as a fall-back.

    my $IndexMappings = $IndexDriver->IndexSettings();

Returns a hash reference including the index settings.

IndexMappings()

This method provides the index field mappings to be used for the related index.

    my $IndexMappings = $IndexDriver->IndexMappings();

Returns a hash reference including the field mapping definitions.

FilterJoin()

This method provides join statements to other DocumentTypes (indices), with permission checks for queries, that affects the own query results.

    my $FilterJoin = $IndexDriver->FilterJoin();

Returns a hash reference including the filter join information.

Filter()

This method provides filter statements, based on agent and customer information.

    my $Filter = $IndexDriver->Filter();

Returns a hash reference including the filter queries.

DocumentPermissionMap()

This method provides a map for permission fields in local documents. Those permissions are used to automatically generate query filter entries, that limits the access to documents.

Possible map keys are 'GroupID', 'UserID', 'CustomerUserID' and 'CustomerID'. The values may be either field names as strings or arrays of field names.

    my $Permission = $IndexDriver->DocumentPermissionMap();

Returns:

    {
        GroupID        => 'GroupID',
        UserID         => [ 'OwnerID', 'ResponsibleID' ],
        CustomerUserID => 'CustomerUserID',
        CustomerID     => 'CustomerID',
    }

DocumentList()

The list of document id's that still needs to be indexed or that are marked for re-indexing.

    my $DocumentList = $IndexDriver->DocumentList();

Returns

    - an array reference, containing the document id's that needs to be indexed or updated.

DocumentGet()

Get the real document data for a list of DocumentIDs to be displayed or indexed.

    my $DocumentData = $IndexDriver->DocumentGet();

Returns

    - an array reference, containing the document id's that needs to be indexed or updated.

DocumentStatus()

The amount of indexed an generally available documents.

    my $DocumentStatus = $IndexDriver->DocumentStatus();

Returns

    - a hash reference, containing the amount of indexed an generally available documents.

SearchableSortableFieldsGet()

This method is used to gather the searchable and sortable fields for the current index driver.

    my $Result = $IndexDriver->SearchableSortableFieldsGet();

Returns a hash reference including the searchable and sortable fields.

SortableFieldTransform()

This method is used to try to find the correct sort field from a predefined list of of alternative field names for the current for the current index driver. If the field is correct or can't be found the in the driver alternative list the original field name is sent back.

The same field could have different alternative names among the index driver.

    my $Result = $IndexDriver->SortableFieldTransform('SomeField');

Returns:

    $Result = 'SomeOtherField';         # or 'SomeField' (in case of correct or missing transformation field)

PredefinedFiltersLookup()

Provides the related filter structures for a filter identifier, that can either be used for real query filtering or inside filter/filters aggregations.

    my $Filter = $IndexDriver->PredefinedFiltersLookup(
        Identifier => 'MyFilterIdentifier',
    )

Returns

    - a hash reference, containing the related filter structure of the given identifier.

PredefinedFilters()

Provides the possible pre defined filters, of the related index driver, which contain identifiers and human readable labels for the filters, to be displayed in frontends.

Returns

    - an array reference, containing the pre defined filters.

FilterAggregations()

Converts all pre defined filters, that are probably available in the current document type, to a related filters aggregation structure, that can be used to count the possible results, that would be returned, if such filters were used.

The document counts for the different pre defined filters, relates on the query string, as well as the related filters, that are applied by the caller (CustomFilters), the permission handling, filter joins and/or filters, that are automatically applied by the related index driver.

For more information about the filters aggregation, please refer to https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-filters-aggregation.html.

Returns

    - a hash reference, containing the named filter entries for the filters aggregation.

UsedPipelines()

This method provides a list of pipelines used by the driver

    my $UsedPipelines = $IndexDriver->UsedPipelines();

Returns an array reference with the name of all used pipelines.

UsedDynamicTemplates()

This method provides a list of dynamic templates used by the index driver

The dynamic template definitions are used to set mappings to dynamically created fields (i.e. in fields of type object).

For more information about dynamic templates and it's usage, please refer to https://www.elastic.co/guide/en/elasticsearch/reference/current/dynamic-templates.html.

    my $UsedDynamicTemplates = $IndexDriver->UsedDynamicTemplates();

Returns an array reference with the name of all used dynamic templates.

PRIVATE INTERFACE

_GetFlatTreeList()

This helper method is used to convert a simple key value list with ancestors in the value e.g. Grandparent::Parent::Son into a two level tree.

    my $FlatTreeList = $IndexDriver->_GetFlatTreeList(
        List => {
            1 => 'GrandFatherA',
            2 => 'GrandFatherB',
            3 => 'GrandFatherA::FatherA',
            4 => 'GrandFatherB::FatherB',
            5 => 'GrandFatherB::FatherB::SonA',
            6 => 'GrandFatherB::FatherB::SonB',
        },
    );

    $FlatTreeList = {
        0 => {
            1 => 'GrandFatherA',
            2 => 'GrandFatherB',
        },
        1 => {
            3 => 'FatherA',
        },
        2 => {
            4 => 'FatherB',
        },
        4 => {
            5 => 'SonA',
            6 => 'SonB',
        },
    };

_FlatTreeListPredefinedFiltersGet()

This helper method is used to convert a FlatTreeList into a hierarchical filter to be used in searches

    my $PredefinedFilter = $IndexDriver->_GetFlatTreeList(
        FlatTreeList = {
            0 => {
                1 => 'GrandFatherA',
                2 => 'GrandFatherB',
            },
            1 => {
                3 => 'FatherA',
            },
            2 => {
                4 => 'FatherB',
            },
            4 => {
                5 => 'SonA',
                6 => 'SonB',
            },
        },
        ObjectList => {
            1 => 'GrandFatherA',
            2 => 'GrandFatherB',
            3 => 'GrandFatherA::FatherA',
            4 => 'GrandFatherB::FatherB',
            5 => 'GrandFatherB::FatherB::SonA',
            6 => 'GrandFatherB::FatherB::SonB',
        },
        ParentID       => 0,
        BaseIdentifier => 'SomeObjectID'
    );

Returns:

    $PredefinedFilter = [
        {
            Label      => 'GrandFatherA',
            Identifier => 'SomeObjectID1',
            Filters    => [
                {
                    Label      => 'FatherA',
                    Identifier => 'SomeObjectID3',
                },
            ],
        },
        {
            Label      => 'GrandFatherB',
            Identifier => 'SomeObjectID2',
            Filters    => [
                {
                    Label      => 'FatherB',
                    Identifier => 'SomeObjectID4',
                    Filters    => [
                        {
                            Label      => 'SonA',
                            Identifier => 'SomeObjectID5',
                        },
                        {
                            Label      => 'SonB',
                            Identifier => 'SomeObjectIDB',
                        },
                    ],
                },
            ],
        },
    ];

_PredefinedFiltersLookup()

This helper method is used to get the search term for a filter identifier

    my $FilterTerm = $IndexDriver->_PredefinedFiltersLookup(
        Identifier => 'SomeIdentifier1',
    );

Returns:

    $FilterTerm = {
        bool => {
            must => [
                {
                    'term' => {
                        SomeIdentifier => '1',
                    },
                },
            ],
        },
    };

_BuildPredefinedFiltersLookupMap()

This helper method is used to get the search term for a filter identifier

    my $FilterMapping = $IndexDriver->_BuildPredefinedFiltersLookupMap()

Returns:

    $FilterMapping = {
        SomeIdentifier1 => {
            must => [
                {
                    'term' => {
                        SomeIdentifier => '1',
                    },
                },
            ],
        },
        SomeIdentifier2 => {
            must => [
                {
                    'term' => {
                        SomeIdentifier => '2',
                    },
                },
            ],
        },
    };

_BuildCustomDrivers()

Initializes the CustomDriver attribute. Returns the instantiated custom index driver objects, that can be used to modify index structures and configurations and information for certain DocumentType.

Scroll to Top