xi/search-bundle

There is no license information available for the latest version (dev-master) of this package.

Xi Search Bundle provides you frontend logic for elasticsearch

Installs: 514

Dependents: 1

Suggesters: 0

Security: 0

Stars: 3

Watchers: 1

Forks: 1

Open Issues: 1

Type:symfony-bundle

dev-master 2012-09-04 11:31 UTC

This package is not auto-updated.

Last update: 2024-12-21 14:37:44 UTC


README

XiSearchBundle provides simple way to display your search data when you do not know exactly what kind of data to expect.

You can use XiSearchBundle with any searchengine as XiSearchBundle provides you interfaces that your final search data object structure must implement.

Installing

deps -file

[XiSearchBundle]
    git=http://github.com/xi-project/xi-bundle-search.git
    target=/bundles/Xi/Bundle/SearchBundle

autoload.php file

<?php
'Xi\\Bundle'       => __DIR__.'/../vendor/bundles',
?>

appKernel.php -file

<?php
            new Xi\Bundle\SearchBundle\XiSearchBundle(), 
?>

routing.yml -file

XiSearchBundle:
    resource: "@XiSearchBundle/Resources/config/routing.yml"
    prefix:   /

config.yml -file

xi_search:
    result_renderer_extensions:
        acmeType: acmeType_renderer_extension
    default_limit: 50

extend ajaxForm (from ajaxbundle) and make sure you bind your custom class as your ajax form handler (see ajaxbundle documentation)

class App.AjaxForm.YourCustomClass extends App.AjaxForm.Default

    xiSearchResultCallback: (content) ->
        @searchResult =  $(@element).siblings('.search-result')
        if !@searchResult.length
            $(@element).after('<div class="search-result"></div>')
            @searchResult =  $(@element).siblings('.search-result')

        @searchResult.html(content)

Integration to ElasticSearch

Probably most easiest way to use this bundle is to use it with ElasticSearch because XiSearchBundle provides you premade implementation for it. This however requires FOQElasticaBundle to work.

Pagination

Pagination uses knp-pagination bundle, and it's on by default

Suppose the search is retrieved via ajax, there's a jquery plugin included that binds the received pagination's logic to the actual search form with javascript.

As the pagination generally uses the search forms default fields, only the indices need configuration. page, term and submit button values can also be overridden

$('#search-result-container').xiSearchPaginate
        indices: ['#xi_searchbundle_searchtype_index_0', '#xi_searchbundle_searchtype_index_1', ...]

For these bindings to work, configure the knp pagination to use the proper pagination template

knp_paginator:
    page_range: 9                      # default page range used in pagination control
    default_options:
        page_name: page                # page query parameter name
        sort_field_name: sort          # sort field query parameter name
        sort_direction_name: direction # sort direction query parameter name
        distinct: true                 # ensure distinct results, useful when ORM queries are using GROUP BY statements
    template:
        pagination: XiSearchBundle:Pagination:sliding.html.twig     # sliding pagination controls template
        sortable: KnpPaginatorBundle:Pagination:sortable_link.html.twig # sort link template