lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Fraschetti <>
Subject Re: range and content query
Date Mon, 20 Sep 2004 06:57:20 GMT
I've more or less figured out the query string required to get a range
of docs.. say date[0 TO 10]    assuming my dates are from 1 to 10 (for
the sake of this example) ... my query has results that I don't
understand. if i do from 0 TO 10, then I only get results matching
0,1,10  ... if i do 0 TO 8, i get all results ... from 0 to 10...   if
i do   1 TO 5  ... then i get results 1,2,3,4,5,10  ... very strange.

here is how my query looks...
query: +date_field:[1 TO 5]

here is how the date was added...
Document doc = new Document();
doc.add(Field.UnIndexed("arcpath_field", filename));
doc.add(Field.Keyword("date_field", date));
doc.add(Field.Text("content_field", content));

I tried Field.Text for the date and also received the same results.
Essentially I have a loop to add 11 strings... indexes 0 to 10... and
add "doc0", "0", "some text"  for each..  and the results i get as as
explained above... any ideas?

Here is my simple searching code.. i'm currently not searching for any
text... i just want to test the range feature right now....

query_string = " +("+DATE_FIELD+":["+start_date+" TO "+end_date+"])";
Searcher searcher = new IndexSearcher(index_path);
QueryParser parser = new QueryParser(CONTENT_FIELD, new StandardAnalyzer());
Query query = parser.parse(query_string);
System.out.println("query: "+query.toString());
Hits hits =;

On Mon, 20 Sep 2004 08:24:17 +0200, Morus Walter <> wrote:
> Chris Fraschetti writes:
> > can someone assist me in building or deny the possibility of combing a
> > range query and a standard query?
> >
> > say for instance i have two fields i'm searching on... one being the a
> > field with an epoch date associated with the entry, and the
> > content....  so how can I make a query to select a range of thos
> > epochs, as well as search through the content? can it be done in one
> > query, or do I have to perform a query upon a query, and if so, what
> > might the syntax look like?
> > 
> if you create the query using the API use a boolean query to combine
> the two basic queries.
> If you use query parser use AND or OR.
> Note that range queries are expanded into boolean queries (OR combined)
> which may be a problem if the number of terms matching the range is too
> big. Depends on your date entries and especially how precise they are.
> Alternatively you might consider using a filter.
>        Morus

Chris Fraschetti, Student CompSci System Admin
University of San Francisco
e |

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message