You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by voidmind <vo...@gmail.com> on 2016/11/11 14:59:18 UTC

How exclude empty fields?

Hi,

I have indexed content about Promotions with effectiveDate and endDate
fields for when the promotions start and end.

I want to query for expired promotions so I do have this criteria, which
works fine:

+Promotion.endDate:[20000101000000TOvariable containing yesterday's date]

The issue I have is that some promotions are permanent so they don't have
an endDate set.

I tried doing:

( +Promotion.endDate:[20000101000000TOvariable containing yesterday's date]
|| -Promotion.endDate:* )

But it doesn't seem to work because the promotions with no endDate are in
my results (empty endDate fields are not indexed apparently)

How would I exclude content that doesn't have an endDate set?

Thanks,
Alexandre Leduc

Re: How exclude empty fields?

Posted by Ahmet Arslan <io...@yahoo.com.INVALID>.
Hi,

Match all docs query minus Promotion.endDate:[* TO *]
+*:* -Promotion.endDate:[* TO *]

Ahmet


On Friday, November 11, 2016 5:59 PM, voidmind <vo...@gmail.com> wrote:
Hi,

I have indexed content about Promotions with effectiveDate and endDate
fields for when the promotions start and end.

I want to query for expired promotions so I do have this criteria, which
works fine:

+Promotion.endDate:[20000101000000TOvariable containing yesterday's date]

The issue I have is that some promotions are permanent so they don't have
an endDate set.

I tried doing:

( +Promotion.endDate:[20000101000000TOvariable containing yesterday's date]
|| -Promotion.endDate:* )

But it doesn't seem to work because the promotions with no endDate are in
my results (empty endDate fields are not indexed apparently)

How would I exclude content that doesn't have an endDate set?

Thanks,
Alexandre Leduc

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Re: How exclude empty fields?

Posted by Chris Hostetter <ho...@fucit.org>.
: The issue I have is that some promotions are permanent so they don't have
: an endDate set.
: 
: I tried doing:
: 
: ( +Promotion.endDate:[20000101000000TOvariable containing yesterday's date]
: || -Promotion.endDate:* )

1) mixing prefix ops with "||" like this is most certainly not doing what 
you think...

https://lucidworks.com/blog/why-not-and-or-and-not/

2) combine that with Ahmet's point about needing a "MatchAllDocsQuery" to 
"select all docs" from which you can thin "exclude docs with an endDate" 
to give you the final results of "docs w/o an endDate" ...

BooleanQuery(
  Should(NumericRangeQuery("endDate:[X TO Y]"))
  Should(BooleanQuery(
    Must(MatchAllDocsQuery())
    MustNot(FieldValueQuery("endDate"))
  ))
)

...either that, or index a new boolean field "permenant" and then simplify 
your query to basically just be "endDate:[X TO Y] OR permentant:true"







-Hoss
http://www.lucidworks.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org