有关php调用lucene(JAVA)代码的问题
最近想使用网页显示Lucene搜索的结果,网上说用Php和javabridge可以,但是,我使用javabridge里面的example或者自己写的类都不行。
apache2.2+php5+mysql
现在是可以调用java自己的类如java.lang.String,但是自己写的不行啊。。。而且javabridge里面有一个例子是这样的:
<!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
--><?php include_once ("java/Java.inc");
java_autoload("lucene.jar");
use java\lang\System as SYS;
use java\io as IO;
use java\util as Util;
use org\apache\lucene as Lucene;
try {
echo "indexing ... ";
/* create the index files in the tmp dir */
$tmp = create_index_dir();
$analyzer = new Lucene\analysis\standard\StandardAnalyzer();
$writer = new Lucene\index\IndexWriter($tmp, $analyzer, true);
$file = new IO\File(getcwd());
$files = $file->listFiles();
assert (!java_is_null($files));
foreach($files as $f) {
$doc = new Lucene\document\Document();
$doc->add(new Lucene\document\Field(
"name",
$f->getName(),
Lucene\document\Field::type("Store")->YES,
Lucene\document\Field::type("Index")->UN_TOKENIZED));
$writer->addDocument($doc);
}
................
................
................
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号