Scaraffe
Scaraffe

Reputation: 5241

Does Zend Lucene support MultiValued Fields?

I wanted to know if Zend Lucene supports multivalued fields. I tried passing a an array to a field and it doesnt give any errors during indexing. But its not returning any results when i search. Any help is appreciated.

Upvotes: 3

Views: 742

Answers (2)

mexique1
mexique1

Reputation: 1693

Actually, if you add space-separated Text fields, they are stored as multiple fields, this is confirmed in Luke.

$doc->addField(Zend_Search_Lucene_Field :: Text($fieldName, implode(' ', $fieldValue)));

The only problem then is that the values are lower cased because they are tokenized.

Upvotes: 0

typeoneerror
typeoneerror

Reputation: 56998

It doesn't:

Fields are always stored and returned from the index in UTF-8 encoding. Any required conversion to UTF-8 happens automatically.

I would think UTF-8 Encoding an array would not work, unless there's some recursion happening there. You could join the array with a "," or something or serialize or json_encode the array. If you are using it as a search index that might not work though. You could also use the Binary field type if you need to store something more complex like an image or something.

Upvotes: 3

Related Questions