4

I'm adding these fields when I store data in Lucene:

$index->addField(Zend_Search_Lucene_Field::Keyword('id', $entry->id));
$index->addField(Zend_Search_Lucene_Field::Keyword('type', $entry->type));

How can make a query to retrieve only data with a certain type?

I tried:

 $query = "type IN ('a', 'b', 'c')"; // get data that has either of these types
 $this->query->addSubquery(Zend_Search_Lucene_Search_QueryParser::parse($query), true);

but it doesn't work...

ajreal
  • 46,720
  • 11
  • 89
  • 119
Alex
  • 66,732
  • 177
  • 439
  • 641
  • ok, I found out a solution using `type:(a) OR type:(b)` etc.. – Alex Sep 05 '11 at 15:53
  • 3
    Would you please consider to put your comment as an actual answer? It's [OK to self-answer](http://meta.stackexchange.com/questions/12513/should-i-not-answer-my-own-questions/12519#12519) your own question. And it would help to keep the "Unanswered" list clear for questions really still being unanswered^^ – Jürgen Thelen Sep 22 '11 at 12:20

1 Answers1

5

Well my solution was:

$query = "type:(a) OR type:(b)";

and it is also ok to write it like this (grouping of fields):

$query = "type:(a OR b)";

Community
  • 1
  • 1
Alex
  • 66,732
  • 177
  • 439
  • 641