Coder Social home page Coder Social logo

ubaranouski-pl / advanced-object-search Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pimcore/advanced-object-search

0.0 0.0 0.0 577 KB

Advanced Object Search bundle provides advanced object search in Pimcore backend powered by Elasticsearch v6/v7

License: Other

PHP 59.47% CSS 0.64% JavaScript 39.89%

advanced-object-search's Introduction

Advanced Object Search via Elasticsearch

Advanced Object Search bundle provides advanced object search in Pimcore backend powered by Elasticsearch v6/v7.

Integration into Pimcore

Installation and Configuration

  • Installer creates all necessary tables.
  • Before starting, setup following configurations in symfony configuration tree:
advanced_object_search:
    # Prefix for index names
    index_name_prefix: 'advanced_object_search_'   
    
    # List of elasticsearch hosts
    es_hosts:
        - 'localhost'
  • call Pimcore command advanced-object-search:update-mapping for creating mappings and advanced-object-search:re-index for indexing data for the first time.

GUI

GUI for creating searches against ES index with

  • saving functionality
  • sharing functionality

Screen

Plugin Hooks

Following event listeners are called automatically

  • pimcore.dataobject.postUpdate - data object is updated in ES index, all child objects are added to update queue.
  • pimcore.dataobject.preDelete - data object is deleted from ES index.
  • pimcore.class.postUpdate - ES index mapping is updated or index recreated if necessary.

Pimcore Console

Functions in Pimcore console.

  • advanced-object-search:process-update-queue --> processes whole update queue of es search index.
  • advanced-object-search:re-index --> Reindex all data objects of given class. Does not delete index first or resets update queue.
  • advanced-object-search:update-mapping --> Deletes and recreates mapping of given classes. Resets update queue for given class.

For details see documentation directly in Pimcore console.

Pimcore Maintenance

With every Pimcore maintenance call, 500 entries of update queue are processed.

API Methods

Create Mapping for data object classes

Per data object class one index with one document type is created.

<?php
/**
* @var \AdvancedObjectSearchBundle\Service $service
 */
$service = $this->get("AdvancedObjectSearchBundle\Service");
$service->updateMapping(ClassDefinition::getByName("Product"));

Update index data

On data object save or via script:

<?php
/**
* @var \AdvancedObjectSearchBundle\Service $service
 */
$service = $this->get("AdvancedObjectSearchBundle\Service");

$objects = Product::getList();
foreach($objects as $object) {
    $service->doUpdateIndexData($object);
}

Search/Filter for data

<?php
/**
* @var \AdvancedObjectSearchBundle\Service $service
 */
$service = $this->get("AdvancedObjectSearchBundle\Service");

//filter for relations via ID
$results = $service->doFilter(3,
    [
        new FilterEntry(
            "objects",
            [
                "type" => "object",
                "id" => 75
            ],
            BoolQuery::SHOULD
        )
    ],
    ""
);



//filter for relations via sub query
$results = $service->doFilter(3,
    [
        [
            "fieldname" => "objects",
            "filterEntryData" => [
                "type" => "object",
                "className" => "Customer",
                "filters" => [
                    [
                        "fieldname" => "firstname",
                        "filterEntryData" => "tom"
                    ]
                ]
            ]
        ],

    ],
    ""
);


// full text search query without filters
$results = $service->doFilter(3,
    [],
    "sony"
);


// filter for several attributes - e.g. number field, input, localized fields
$results = $service->doFilter(3,
    [
        [
            "fieldname" => "price",
            "filterEntryData" => 50.77
        ],
        [
            "fieldname" => "price2",
            "filterEntryData" => [
                "gte" => 50.77,
                "lte" => 50.77
            ]
        ],
        [
            "fieldname" => "keywords",
            "filterEntryData" => "test2",
            "operator" => BoolQuery::SHOULD
        ],
        [
            "fieldname" => "localizedfields",
            "filterEntryData" => [
                "en" => [
                    "fieldname" => "locname",
                    "filterEntryData" => "englname"
                ]
            ]
        ],
        [
            "fieldname" => "localizedfields",
            "filterEntryData" => [
                "de" => [
                    "fieldname" => "locname",
                    "filterEntryData" => "deutname"                
                ]
            ]
        ],
        new FilterEntry("keywords", "testx", BoolQuery::SHOULD)
    ],
    ""
);

Not Supported Data Types

Currently following data types are not supported - but can be added if needed in future versions:

  • ClassificationStore
  • Slider
  • Password
  • Block
  • Table
  • StructuredTable
  • Geographic data types
  • Image data types

Integrate new Data Type

  • Implement Field Definition Adapter by implementing the IFieldDefinitionAdapter interface.
  • Register new Field Definition Adapter as service
  • Add mapping in configuration like
advanced_object_search: 
    field_definition_adapters:
        newDataTypeName: SERVICE_ID_OF_FIELD_DEFINITION_ADAPTER

Extend Filters in the Result Tab

If you want custom filters in the result tab directly without having to create a new advanced object search every time read here on how to extend the result tab with custom filters..

Supported Elastic Search Versions

  • ElasticSearch 6
  • ElasticSearch 7

Upgrade Notes

Upgrade to v3.0.0

  • Reinstall of Bundle might be necessary - due to switch to MigrationInstaller.
  • Update ES mapping and reindex is necessary - run commands advanced-object-search:update-mapping and advanced-object-search:re-index.

Upgrade to v4.0.0

  • Removed BC Layer for old configuration file. Configuration now only in symfony configuration tree.
  • Removed deprecated IFieldDefinitionAdapter, use FieldDefinitionAdapterInterface instead.
  • Data in Elasticsearch might be different, so recheck if you are depending directly on the data in Elasticsearch.
  • Execute all migrations of the bundle.

Upgrade to Pimcore X

  • Update to latest (allowed) bundle version in Pimcore 6.9 and execute all migrations.
  • Make sure you are using ElsaticSearch 7.
  • Then update to Pimcore X.

advanced-object-search's People

Contributors

fashxp avatar brusch avatar weisswurstkanone avatar dvesh3 avatar vmalyk avatar wujku avatar mbolka avatar ruudvdvnb avatar maff avatar jdreesen avatar danmichaelo avatar akansh0581 avatar ascheider avatar alternateif avatar mschweiger90 avatar blankse avatar skoch98 avatar elements-team avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.