Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6922571
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:25:25+00:00 2026-05-27T10:25:25+00:00

Say my index contains documents with a field called ages. Example entries for ages

  • 0

Say my index contains documents with a field called “ages”. Example entries for “ages” field:

  • 25
  • 24, 28
  • 25, 31

How would I query this so that I get all the documents whose fields contain ages between 20 and 30? I’m using Zend Lucene.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T10:25:25+00:00Added an answer on May 27, 2026 at 10:25 am

    lmgtfy :-

    $from = new Zend_Search_Lucene_Index_Term(20, 'ages');
    $to   = new Zend_Search_Lucene_Index_Term(30, 'ages');
    $query = new Zend_Search_Lucene_Search_Query_Range(
                 $from, $to, true // inclusive
             );
    $hits  = $index->find($query);
    

    Docs:- http://framework.zend.com/manual/en/zend.search.lucene.query-api.html#zend.search.lucene.queries.range

    Both lucene and solr support multivalued.
    For your case, you did not normalized the data very well.
    Reassign the ages field as multivalued,
    the range query is to match one of the value in multivalued.
    That’s mean

    20,29 <-- matched
    20,31 <-- matched
    30,31 <-- does not matched
    

    If you need to match ALL value between 20 to 30,

    20,21,30 <-- matched
    19,21,30 <-- not matched
    

    You can use another field(s),
    like :-

    age_20_30 : store 1 (when all ages are between 20 to 30), else 0
    age_30_40 : store 1 (when all ages are between 30 to 40), else 0
    ... etc
    

    After that, you can change to search on age_20_30:1.
    This is like telling lucene to work on the summary results

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have a web page ( /index.html ) that contains the following
I have a table (lets say it has one column called 'colLanguage') that contains
I now understand that a clustered index contains all of the row data, not
So let's say I have a compound index on a table that indexes 4
Say I have jquery code like this: html += '<div class=index>' + item.index +
I've got a RESTful resource (let's say posts ) that excludes the index action.
I have a Lucene index that has several documents in it. Each document has
I'm trying to make a HTML page (lets say index.html) that will have a
Let's say I have an Array that contains more than three repetitions of a
My website has a structure like this: root folder contains --- > 1)index.php 2)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.