PHP Development

Lucene - Zend

I’m not sure if this is the norm, I stumbled across the answer while banging my head against a wall trying to integrate a Lucene search through the ZF framework (zend). So, as an example I wanted to run the following code block. It simply adds a document and some fields to the the document and some unstored content.. pretty basic.

Notice the last line though…. “index->commit();”

You will have to look hard to find the use or reason for using this, but if you do not and your script ends pre-maturely, there is a chance you will not get the results you expect. The examples I have seen do not mention that if you do not do this and you run and exit or throw an exception prior to the front controller dispatching, it goes to shit.

Just as an fyi many people after the commit will toss in the index->optimize,.. it’s a good practice, I just did not do it for this example.

Example code:

$index = Zend_Search_Lucene::create(SEARCH_DIR.'articles/'.$data['article_index']);
$doc = new Zend_Search_Lucene_Document();
$doc->addField(Zend_Search_Lucene_Field::Text(’title’, $data['article_title']));
$doc->addField(Zend_Search_Lucene_Field::Text(’description’, $data['article_short']));
$doc->addField(Zend_Search_Lucene_Field::Text(’link’, $data['article_url']));
$doc->addField(Zend_Search_Lucene_Field::UnStored(’contents’, $data['index_content']));
$index->addDocument($doc);
$index->commit();

Vexed Daily

I loath car shopping

So it’s that time again; time to purchase a vehicle. I hate this process, between the push and pull of over zealous car dealers and my inability to decide on a vehicle make, model, type, or price; the process is daunting at best.

To start with, my personal struggle. I’m getting older, so practicality has started to creep in on my aging mind (don’t tell anyone). So that combined with my yearn to rip the road apart with some high horse powered octane burning vehicle of death, I am at a loss.

Cylinders…. 4,5,6,8
4.. Just seems under powered…
5.. Engineering at it’s best,… Audi,.. a bit overpriced, but nice
6.. Seems to be a good choice, the problem is practical design often is in a 4cy. model.
8.. Fun… to much fun? Gas eater, not that I have ever cared.. usually a larger price tag.

Dealers:
Holy shit… Is there a school that updates these people on how to be an asshole that rapes people? They have always been annoying pains, but seems more so now. Dealers,… we are not all stupid, when I come to look at a car I have most likely checked it out first, please do not try to convince me that the vehicle brand new that is 29k is some how worth 38k when you sell it to me.

The search continues…..

Vexed Daily

Somalia’s Piracy

“It’s very simple,” Choong said. “The minute they notice small boats approaching their ship, they should take evasive measures, increase speed and at the same time radio for help. A lot of ships escape by doing this.”

I’m sure a cargo ships ability to take evasive measures is an example of nautical wonder…..

Ships also should install barbed wire or similar deterrents on the ship to prevent pirates from scaling the sides and boarding.

or RPG’s

Roger Middleton, a piracy expert at the London-based think-tank Chatham House, said ships also can travel at full speed, and take evasive procedures such as using water cannons and fire hoses to flood the engines of the pirates’ skiffs.

Ya,.. lets bring a knife to a gun fight. What I find funny about this statement is in the article they state that they do not want to arm the crews of the cargo ship in fear of escalating a confrontational situation, yet they suggest that they squirt these people with water?… cause thats not going to piss them off; and honestly I don’t want to squirt water at a guy with an M-16….

just my 2 cents.

Full Story

Vexed Daily

Band-aid the problem India….

Much like the developers from India that I work with, why solve the problem when you can put a temporary band-aid on it. One word…. -sad-

THE Mumbai City Council has acquired a new weapon to combat the increasingly putrid stench emanating from two of the city’s biggest rubbish dumps: 42,000 litres of deodorant.

Sanil Supreme, a sweet-smelling herbal spray, will be squirted each day in an attempt to neutralise the increasingly offensive odour of the massive Deonar and Mulund landfill sites after a decree from Ahmad Karim, the head of the city’s solid-waste management division, The Australian reports.

Full Story…
found via: Thanks Pizza.

« Prev - Next »