|
|||
|
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();
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');
Thank you in advance! |
|
|||
|
I am having problems with this myself.. I have tried a few different analyzers including UTF8 one and the "TextNum" ones with no luck. I have tried doing the numeric field as a Text/Keyword/UnStored also.
Any help is appreciated... - aba |
|
|||
|
I would also be interested to see what analyzer allows integer searches.
FYI, I used md5 to convert my database key to a unique searchable entry for each index record: PHP Code:
|
|
|||
|
Ok, after messing with this for a long time I figured out that other people can't search for numeric data. Here is a solution:
PHP Code:
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|