I can see two problems - the field type and how you're searching against it.
1) If a field is UnIndexed, AFAIK it can't be searched for, it's simply
stored with the record itself and is returned along with the search
results. You might use this for some metadata such as the URL for a
page. In order to be able to match it, I believe you need to be running
the search against one of the column types that is indexed (Keyword,
Text, Unstored)
2) When using fields that don't fit through tokenization (e.g. numeric
fields), I found I wasn't able to ->find using the query parser, but
instead had to build it in the API (which makes sense). So, you'll need
something like below:
$query = new Zend_Search_Lucene_Search_Query_Term(new
Zend_Search_Lucene_Index_Term((int) $page->getId (), "pid"));
$hits = $index->find($query);
There are, of course, other ways of implementing it, but the key thing
here is that it has to go through the query API rather than the query
parser.
Hope this helps
Pete
Mathew Byrne wrote:
On Apr 19, 2008, at 1:48 AM, Eric Marden wrote:
Index/Store something Unique for each document. Such as DB ID or Unique
URL/Path, etc.
Ok, I'm doing that:
$doc->addField (Zend_Search_Lucene_Field::UnIndexed ('pid',
$page->getId ()));
Retrieve document by this unique value, and get its Lucene Document ID
Delete by this ID.
Ok, so I'd assume the following would work:
$hits = $index->find('pid:' . (int) $page->getId ());
But as far as I can tell this is not returning anything. Should I be
storing this unique identifier in any particular type of field? Will
integer values be stripped out or something?
--
Eric Marden
-----Original Message-----
From: Mathew Byrne [mailto:[EMAIL PROTECTED]
Sent: Friday, April 18, 2008 4:25 AM
To: fw-general@lists.zend.com
Subject: [fw-general] Updating Documents with Lucene
The documentation for Zend_Search_Lucene isn't really clear about how to
find existing documents in the current index. Take the following from
the docs:
$removePath = ...;
$hits = $index->find('path:' . $removePath); foreach ($hits as $hit) {
$index->delete($hit->id);
}
Now I assume that this means that you've registered a field named 'path'
for each document in the index.
For my particular application pages are identified in the index and in
the database by an integer identifier. But for some reason the following
doesn't work correctly:
$page = ...;
$hits = $index->find('pid:' . (int) $page->getId (); // Doesn't return
any hits!
I have an inkling that the $index->find () method is stripping out all
non-alphabetical values. Is this the case and is there a work around for
this??
--
Mathew Byrne
http://www.matbyrne.com/