I've been trying to set up a very basic search engine using the Whoosh modules in python called on from PHP. I had it working until I upgraded the modules for some additional features I needed. At which point an odd bug seemed to appear. Any print statement after the line "searcher = ixtemp.searcher()" is not being received by the PHP script.
The python search script is called from PHP and the first result is displayed with the following commands
exec("python print.py",$output,$ret_code);
echo $output[0];
The python script -
from whoosh.index import open_dir
ixtemp = open_dir("index")
searcher = ixtemp.searcher()
results = searcher.find("content", u""+"test")
for k in results:
print k['filename']
Running the PHP now gives the following error -
Notice: Undefined offset: 0 in /opt/lampp/htdocs/new/search.php on line 17
The python script is working when I run it by itself. After a little investigation it seems that any print statements before the line "searcher = ixtemp.searcher()" can be read by the PHP, but all after are not received by the PHP script. I've also tried the popen() and proc_open functions too, but they have the same problem.
Any ideas on what the problem is or how I can work around it?
Thanks
I ran out ideas and decided to chmod 777 the directory...and...it worked. I'm not sure why it did since data could always be sent above the searcher() function anyway.
Perhaps while initiating the search the method was trying to modify protected index files?
But that couldn't in itself be the problem since it always worked from the interpreter.
So it must have been the PHP file. It seems to have been protection against indirectly modifying the index files.