Can I use Lucene with PHP ? I don't want to use Zend. Can I use in native PHP (not framework) ?
-
1"Can I" is a very wide question. Of course you "can". However, is it reasonable? Please expand your question to illustrate how you intend to use it. – gahooa Jan 06 '10 at 02:59
-
I want to use full text search with Lucene. MySQL too slow for searching over 8 millions record. So, I want to try with Lucene – saturngod Jan 06 '10 at 03:50
6 Answers
I would recommend using Apache SOLR as your Lucene backend and connecting via web service calls from your PHP code.
I'd also note that it's easy to pick and choose components of Zend Framework for use in your application without loading the entire framework. You could use Zend_Search_Lucene in your site and forego Zend's MVC, database, and related components.

- 31,139
- 18
- 86
- 102
-
-
7I'd like to tag on to that a recommendation (personal preference) that you use JSON rather than XML for retrieving your results. – Brian Jan 06 '10 at 20:36
Also worth noting, SOLR (http://lucene.apache.org/solr/) has a simple HTTP API, and is built on top of Lucene, so if it provides what you need, then that's an easy answer!
I don't have direct experience with Lucene with PHP, so I'll defer to the experts on that.

- 131,293
- 12
- 98
- 101
I recommend apache SOLR and then use php extension for solr. http://php.net/manual/en/book.solr.php
No need for zend framework, just native php

- 113
- 9
When you say you don't want to use Zend, I'm assuming you mean you don't want to use the whole Zend Framework. Well you don't have to - the individual Zend components can be used on their own without needing to be part of a Zend framework project.

- 3,478
- 11
- 39
- 53
-
-
2Well I wrote this answer over 5 years ago and back then you would just download the framework, stick it in an include path and then either require_once the file you needed (e.g. Zend/Lucene/Search.php), or use autoloading, and access the class as in the docs. Nowadays we have composer which makes it a lot easier. Zend Lucence from Zend 1 is actually available on composer - https://packagist.org/packages/zf1/zend-search-lucene. Instructions on how to use composer can be found here: https://getcomposer.org/doc/01-basic-usage.md – Gnuffo1 Feb 11 '15 at 14:02
I'm using Lucene with PHP doing system calls on Java, for example:
java ... .SearchFiles -index C:\shop\system\index -high -queries Computer*
I have adapted SearchFiles to produce HTML code but the output may as well be dynamic PHP code (for example an array holding the search results).
The system is very fast and you don't need more than Java on the server.

- 2,336
- 5
- 31
- 40

- 39
- 1
Yeah you can simply code a java module for indexing and searching purpose using apache lucene library. Then you can merge it with php module with php/java bridge or SOAP. It will be quite good learning experience for you.

- 323
- 1
- 5