Thứ Năm, 24 tháng 4, 2014

Introduction to Lucene [Search Using Lucene]

Lucene is a high-performance, scalable information retrieval (search) library developed by Apache Foundation, which can be used for implementing free-text search in web applications. Lucene provides a simple-to-use API, which will provide powerful indexing and searching capability tyour web application. Tread more about Lucene visit http://lucene.apache.org/.



The most importancomponents of the Lucene search library arexplained as follows:

        Index: Lucene index is the datstore that holds all the indexed documents; queries arexecuted against the indetfetch the documents.
        Document: A document is the default building block for a Lucene index; documents can be compared trecords in a table. Each document holds a number of fields upon which queries can be executed.
        FieldEach Lucene documencomprises of one or more fields; it is not necessary that all the fields are indexed, fields can also be stored without indexing.

The Lucene search works based on the index, so it is necessarto have the index updated with the latescontentget the best search results. The following diagram explains the overview of the Lucene search:


Perform the following stepfor installing ZendSearch\Lucene:

1.       ZendSearch\Lucene was not available as a composer packagat the time of writing this book. Sowe will check out the source from the GitHub repository. The repository is available athttps://github.com/zendframework/ZendSearch.
2.       Nexwe need to navigatto the vendor folder:
$ cd /var/www/CommunicationApp/vendor/

3.       Clone the Zend search repository into the vendor folder:
$ git clone https://github.com/zendframework/ZendSearch.git ZendSearch


4.     Nexwe should configure the ZendSearch library using composer:
$ cd ZendSearch/
$ curl -s https://getcomposer.org/installer | php
$ php composer.phar install

5.       Once the library is configured, we will need to define a module-level configuration tstore the index location. To do this, we need to modifCommunicationApp/ module/Users/config/module.config.php, and add a neconfiguration for search_index:
// MODULE CONFIGURATIONS 'module_config' => array('upload_location'   =>   DIR  'image_upload_location'   =>   DIR     
. '/../data/uploads',
. '/../data/images',
'search_index'
=>   DIR
),
. '/../data/search_index'


What just happened?
We have now downloaded and configured the ZendSearch librarfor Zend Framework 2.0; the previous tutorial also provides us with a guideline for downloading and installing packages which cannot be downloaded directly from Composer.

Now thawe have the ZendSearch\Lucene search library installed, our nextask will be to create a Lucene indefor some of the data that is already stored in our communication application.

Không có nhận xét nào:

Đăng nhận xét