Searching for future or "null" dates

2008-09-15 Thread Chris Maxwell

I'm having a lot of trouble getting this query syntax to work correctly. How
can I search for a date, which is either in the future OR missing completely
(meaning open ended)

I've tried -endDate:[* TO *] OR endDate[NOW TO *] but that doesn't work.
Adding parentheses doesn't help either.

Any help would be appreciated.
-- 
View this message in context: 
http://www.nabble.com/Searching-for-future-or-%22null%22-dates-tp19502167p19502167.html
Sent from the Solr - User mailing list archive at Nabble.com.



Re: AW: Searching for future or "null" dates

2008-09-16 Thread Chris Maxwell



Christian Kolodziej wrote:
> 
> Hi Chris,
> 
>>I'm having a lot of trouble getting this query syntax to work correctly.
>>How
>>can I search for a date, which is either in the future OR missing
>>completely
>>(meaning open ended)
>>
>>I've tried -endDate:[* TO *] OR endDate[NOW TO *] but that doesn't work.
>>Adding parentheses doesn't help either.
> 
> Why do you use a range query for the endDate, that is not set? It's not
> tested yet but try -endDate:19700101T00:00:00Z (if it's a date field) or
> -date:0 (if you have saved timestamp). Another solution I would try is to
> use specific dates instead of NOW or * for the future.
> 
> Can you post the results of your trials, this might be interesting for
> other users, too.
> 
> Best regards,
> Christian
> 
> 
> 


Sorry, I think I over simplified my example, let me clarify my reasoning.
I'm searching for products that have a start date in the past up to the
present and have a end date in the present/future or none at all. I had
looked into searching for null dates and had come across the -date[* : *]
syntax, which searches for the absence of the index value for the field
specified.

Example: ( I thought this one would work)
product:foo AND startDate:[* TO NOW] AND (endDate:[NOW TO *] OR -endDate[* :
*])

I've gotten the syntax below to work but it seems overkill and redundant

((product:foo AND startDate:[* TO NOW] AND endDate:[NOW TO *]) OR
(product:foo AND startDate:[* TO NOW] AND (-endDate:[* TO *])))

Again I'm simplifying the actual query syntax for this example, but it seems
having to restate the product and startDate again in the query is overkill.
I thought their might be an easier way.

Thanks for your example. I'll try it out and post back.


-- 
View this message in context: 
http://www.nabble.com/Searching-for-future-or-%22null%22-dates-tp19502167p19515122.html
Sent from the Solr - User mailing list archive at Nabble.com.



Re: AW: Searching for future or "null" dates

2008-09-16 Thread Chris Maxwell

Yes your right I mistyped when I said [* : *]. I did mean [* TO *]


hossman wrote:
> 
> 
> : present and have a end date in the present/future or none at all. I had
> : looked into searching for null dates and had come across the -date[* :
> *]
> : syntax, which searches for the absence of the index value for the field
> : specified.
> 
> to clarify: that isn't valid syntax.  i think you are confusing two 
> things...
> 
> 1) has a value in field "foo": foo:[* TO *]
> 2) match all docs: *:*
> 
> 
> -Hoss
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Searching-for-future-or-%22null%22-dates-tp19502167p19519922.html
Sent from the Solr - User mailing list archive at Nabble.com.



RE: Searching for future or "null" dates

2008-09-18 Thread Chris Maxwell

Here is what I was able to get working with your help.

(productId:(102685804)) AND liveDate:[* TO NOW] AND ((endDate:[NOW TO *]) OR
((*:* -endDate:[* TO *])))

the *:* is what I was missing.

Thanks for your help.



hossman wrote:
> 
> 
> : If the query stars with a negative clause Lucene returns nothing.
> 
> that's not true.  If a "Query" in lucene is a BooleanQuery that only 
> contains negative clauses, then Lucene returns nothing (because nothing is 
> positively selected) ... but it if there is a mix of negative lcauses and 
> positive clauses doesn't matter what order the clauses are in.
> 
> in *solr* there is code that attempts to detect a query containing purely 
> negative clauses and it adds a "MatchAllDocs" query in that case -- but it 
> only works at the top level of a query.  nested queries like this...
> 
> +fieldA:foo +(-fieldB:bar -fieldC:baz)
> 
> ...won't work as you expect, because that nested query is only negative 
> clauses.  you can add your own MatchAllDocs query explicitly using the *:* 
> syntax
> 
> +fieldA:foo +(*:* -fieldB:bar -fieldC:baz)
> 
> :  endDate[NOW TO *] OR -endDate:[* TO *]
> 
> side note: you really, REALLY don't wnat to mix the "+/-" syntax with 
> "ANT/OR/NOT" .. it almost never works out the way you expect...
> 
> : >can I search for a date, which is either in the future OR missing 
> : >completely (meaning open ended)
> : >
> : >I've tried -endDate:[* TO *] OR endDate[NOW TO *] but that doesn't
> work.
> 
> unless you've set the default op to "AND" this should work...
> 
>   fq = endDate:[NOW TO *] (*:* -endDate:[* TO *])
> 
> 
> -Hoss
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Searching-for-future-or-%22null%22-dates-tp19502167p19563117.html
Sent from the Solr - User mailing list archive at Nabble.com.



RE: Searching for future or "null" dates

2008-09-22 Thread Chris Maxwell

Thanks I'll try it out.


hossman wrote:
> 
> 
> : Here is what I was able to get working with your help.
> : 
> : (productId:(102685804)) AND liveDate:[* TO NOW] AND ((endDate:[NOW TO
> *]) OR
> : ((*:* -endDate:[* TO *])))
> : 
> : the *:* is what I was missing.
> 
> Please, PLEASE ... do yourself a favor and stop using "AND" and "OR" ...  
> food will taste better, flowers will smell fresher, and the world will be 
> a happy shinny place...
> 
> +productId:102685804 +liveDate:[* TO NOW] +(endDate:[NOW TO *] (*:*
> -endDate:[* TO *]))
> 
> 
> 
> -Hoss
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Searching-for-future-or-%22null%22-dates-tp19502167p19621485.html
Sent from the Solr - User mailing list archive at Nabble.com.