apache / lucene

Apache Lucene open-source search software
https://lucene.apache.org/
Apache License 2.0
2.62k stars 1.02k forks source link

Search Results Filtering Based on Bitwise Operations on Integer Fields [LUCENE-2460] #3534

Open asfimport opened 14 years ago

asfimport commented 14 years ago

This package makes it possible to filter results returned from a query based on the results of a bitwise operation on an integer field in the documents returned from the pre-constructed query.

You can perform three basic types of operations on these integer fields

You can also negate the results of these operations.

For example, imagine there is an integer field in the index named "flags" with the a value 8 (1000 in binary). The following results will be expected :

  1. A source value of 8 will match during a BitwiseOperation.BITWISE_AND operation, with negate set to false.
  2. A source value of 4 will match during a BitwiseOperation.BITWISE_AND operation, with negate set to true.

The BitwiseFilter constructor accepts the following values


Migrated from LUCENE-2460 by Israel Ekpo, 3 votes, updated May 09 2016 Attachments: LUCENE-2460-bitwise.tar.gz

asfimport commented 14 years ago

Israel Ekpo (migrated from JIRA)

Attaching the package containing the BitwiseFilter class

asfimport commented 11 years ago

Steven Rowe (@sarowe) (migrated from JIRA)

Bulk move 4.4 issues to 4.5 and 5.0

asfimport commented 10 years ago

Uwe Schindler (@uschindler) (migrated from JIRA)

Move issue to Lucene 4.9.

NavidMitchell commented 1 month ago

It would be nice to have this feature supported.

gsmiller commented 1 month ago

@NavidMitchell I'm not sure if there's a more convenient way to do this, but note that you can do this using Expressions compiled from JavascriptCompiler since the compiler supports bitwise operations. You can create a custom Query implementation on top of a DoubleValuesSource created form the expression that runs bitwise operations against a numeric doc values field. (I haven't looked the patch associated with this issue since it's pretty old at this point, but just wanted to let you know that I think what this issue describes is actually possible)

NavidMitchell commented 1 month ago

Thank you