Hello there,
I just set up the Zend Lucene Search Engine (ZF 1.0.1) and want to use it for indexing a huge number of userdata. I already have a unique numeric ID for each user, so I try to reuse that for retrieving the document for a certain user (in order to delete and re-add it).
The problem is now: Lucene does not let me search for numeric stuff.
I tried all this:
1. Using the Zend_Search_Lucene_Field::Text function when adding fields, instead of Zend_Search_Lucene_Field::Keyword,
2. Instead of adding ...Keyword('id', $userId) I used a custom fieldname
But - in all cases, what ever I do , I am facing the Issues that
1. Lucene overwrites the id with it's own if I write ...::Keyword('id', $userId)
2. Disregarding if I search in the predefined id column or in my custom 'userid' column, - when I use numeric values for the ID, Lucene does not find any hit.
So, it seems - in this Version of Lucene - it overwrites the Document-id ALWAYS with it's own id, and searching for numeric values is simply not possible.
My Workaround was now, to convert the numeric ID into some String (e.g. a hash) - then it works perfectly - but it's not a very clean solution in my opinion.
So, who can tell my what I'm doin wrong?
Here's the code snippet how I'm indexing:
Code:
$index = new Zend_Search_Lucene($location);
$doc = new Zend_Search_Lucene_Document();
$doc->addField(Zend_Search_Lucene_Field::Text('id' , $userId, 'utf-8'));
$doc->addField(Zend_Search_Lucene_Field::Keyword('userid' ,$userId, 'utf-8'));
$index->addDocument($doc);
$index->commit();
And this is how I try to search:
Code:
// Search for lucene internal ID which has been overwritten but does not work anyway
$hits = $index->find('id:113');
// Search for my Custom user id which also does not deliver any hit
$hits = $index->find('userid:113');
Btw: I already approved, all the data is stored correctly in the index - at least I can verify all the data when I display the content of all documents in the index.
Thank you in advance!