hi guys,
i try write this java code in php using php java bridge:


when i found this line:

IndexReader reader = DirectoryReader.open(index);

i dont get it how to write it in php.
i've tried but error result.

when it be like this:

Query q = new QueryParser(Version.LUCENE_40, "content", analyzer).parse(querystr);

i write in php like below:

$query = new Query\QueryParser($version->LUCENE_43,'content',$analyzer);

it's no error.

so, could you help me how to write it in php??
thanks in advance.

Member Avatar

i dont get it how to write it in php.

@el macho

It's not PHP you are having issue, it's creating a mysql query to connected to the database.

I don't think you have query yet because if you did you would have provided that already.

im using laravel 4,
i have add document, here is my code,


use java\lang\System as SYS;
use java\io as IO;

use org\apache\lucene\util as Util;
//use org\apache\lucene as Lucene;
use org\apache\lucene\analysis\id as Id;
use org\apache\lucene\document as Document;
use org\apache\lucene\index as Index;
use org\apache\lucene\queryparser\classic as Query;
use org\apache\lucene\search as Search;
use org\apache\lucene\store as Store;

class SearchController extends BaseController

    function SearchQuery()
        $version = new Util\Version();
        //echo $version->LUCENE_43;

        $analyzer = new Id\IndonesianAnalyzer($version->LUCENE_43);
        $index = new Store\RAMDirectory();
        $config = new Index\IndexWriterConfig($version->LUCENE_43,$analyzer);
        $writer = new Index\IndexWriter($index,$config);

        //create index
        $datadoc = documents::all();
        foreach($datadoc as $dtdoc)

        $query = new Query\QueryParser($version->LUCENE_43,'content',$analyzer);

        $reader = new Index\IndexReader();
        //$searcher = new Search\IndexSearcher($index);

    function adddoc($writer,$title,$content)
        $doc = new Document\Document();
        $doc->add(new Document\TextField('title',$title,Document\Field::type("Store")->YES));
        $doc->add(new Document\TextField('content',$content,Document\Field::type("Store")->YES));

i just have obstacle to write this code:

IndexReader reader = DirectoryReader.open(index);

bcoz, all i know is to initiate a object in java, use 'new'.
but i dont find in that code, that's why i dont get it.

Member Avatar

im using laravel 4,

@el macho

Not familiar with Java but since you are using laravel 4, then read this:


That link above explain and show how to configurate in laravel framework.


That link above explain and show how to write a query in laravel framework.

You need to used lavavel framework structure tags another words every CMS / frameworks has its own language.