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 to your web application. To read more about Lucene visit http://lucene.apache.org/.
◆ Index: Lucene index is the data store that holds all the indexed documents; queries are executed against the index to fetch the documents.
◆ Document: A document is the default building block for a Lucene index; documents can be compared to records in a table. Each document holds a number of fields upon which queries can be executed.
◆ Field: Each Lucene document comprises 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 necessary to have the index updated with the latest content to get the best search results. The following diagram explains the overview of the Lucene search:
Perform the following steps for installing ZendSearch\Lucene:
1. ZendSearch\Lucene was not available as a composer package at the time of writing this book. So, we will check out the source from the GitHub repository. The repository is available athttps://github.com/zendframework/ZendSearch.
2. Next we need to navigate to 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
$ 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 to store the index location. To do this, we need to modify CommunicationApp/ module/Users/config/module.config.php, and add a new configuration for search_index:
// MODULE CONFIGURATIONS 'module_config' => array('upload_location' => DIR 'image_upload_location' => DIR
. '/../data/uploads',
. '/../data/images',
'search_index'
=> DIR
. '/../data/uploads',
. '/../data/images',
'search_index'
=> DIR
),
. '/../data/search_index'
. '/../data/search_index'
What just happened?
We have now downloaded and configured the ZendSearch library for 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 that we have the ZendSearch\Lucene search library installed, our next task will be to create a Lucene index for 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