0

I have this fields in the index

id    name                   genders          ages
1     "John Doe and Co."     "male male"      "18 20" 
2     'Mr. and Mrs. Joe Dee' "male female"    "25 27"

and here is the code to retrieve both rows

$min_age = '19'
$max_age = '26';

$ages_query = new Zend_Search_Lucene_Search_Query_Range(new Zend_Search_Lucene_Index_Term($min_age, 'ages'), new Zend_Search_Lucene_Index_Term($max_age, 'ages'), TRUE);

$lucene_query = new Zend_Search_Lucene_Search_Query_Boolean();
$lucene_query->addSubquery($ages_query, null);

I only return the second row. Why did I not get the first row when it clearly should be returned based on the range query?

jakub.g
  • 38,512
  • 12
  • 92
  • 130
developarvin
  • 4,940
  • 12
  • 54
  • 100

1 Answers1

0

This is wrong format for ages field, you should break into two fields

age_from : 18
age_to   : 20

Query :-

 +age_from:[19 TO *]
 +age_to:[* TO 26 *]

I not sure you related to this question or not : Zend Lucene and range search on a field with multiple values

But the idea is do not store CSV into lucene.

Community
  • 1
  • 1
ajreal
  • 46,720
  • 11
  • 89
  • 119