You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by AlexxelA <al...@canoe.ca> on 2009/04/08 20:37:40 UTC
Query with bitwise operation
One field of my document I use for solr is an integer. I want to do bitwise
operations on that field in my queries
Ex :
status = 46 (in my solr document)
In want to know if the bit #1 (2¹) = 1 --> (46&2) > 0 ?
or if bit #2 and #3 (2² + 2³) = 1 (46&12) > 0 ?
Can we do something like this :
q=status:((46&2)>0) ?
--
View this message in context: http://www.nabble.com/Query-with-bitwise-operation-tp22956950p22956950.html
Sent from the Solr - User mailing list archive at Nabble.com.
Re: Query with bitwise operation
Posted by Noble Paul നോബിള് नोब्ळ् <no...@gmail.com>.
I guess we must add functions for bitwise operations.
say
* bor
* bxor
* band
* bcompliment
These functionalities are trivial to add and may be useful for people
who are familiar with bit operations
--Noble
On Thu, Apr 9, 2009 at 1:10 AM, Erik Hatcher <er...@ehatchersolutions.com> wrote:
> No, there is no support in the query parser for bit-wise queries like that.
> [Although there might be some funky function query magic that can do
> this?]
>
> My recommendation is to index each bit as a separate field (bit_0, bit_1,
> bit_2....). You could define a dynamicField bit_* as a boolean type. Set
> each bit field value to true or false. And query them separately:
> "bit_2:true AND bit_3:true" for example.
>
> Erik
>
>
>
> On Apr 8, 2009, at 2:37 PM, AlexxelA wrote:
>
>>
>> One field of my document I use for solr is an integer. I want to do
>> bitwise
>> operations on that field in my queries
>>
>> Ex :
>>
>> status = 46 (in my solr document)
>> In want to know if the bit #1 (2¹) = 1 --> (46&2) > 0 ?
>> or if bit #2 and #3 (2² + 2³) = 1 (46&12) > 0 ?
>>
>> Can we do something like this :
>>
>> q=status:((46&2)>0) ?
>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Query-with-bitwise-operation-tp22956950p22956950.html
>> Sent from the Solr - User mailing list archive at Nabble.com.
>
>
--
--Noble Paul
Re: Query with bitwise operation
Posted by Erik Hatcher <er...@ehatchersolutions.com>.
No, there is no support in the query parser for bit-wise queries like
that. [Although there might be some funky function query magic that
can do this?]
My recommendation is to index each bit as a separate field (bit_0,
bit_1, bit_2....). You could define a dynamicField bit_* as a boolean
type. Set each bit field value to true or false. And query them
separately: "bit_2:true AND bit_3:true" for example.
Erik
On Apr 8, 2009, at 2:37 PM, AlexxelA wrote:
>
> One field of my document I use for solr is an integer. I want to do
> bitwise
> operations on that field in my queries
>
> Ex :
>
> status = 46 (in my solr document)
> In want to know if the bit #1 (2¹) = 1 --> (46&2) > 0 ?
> or if bit #2 and #3 (2² + 2³) = 1 (46&12) > 0 ?
>
> Can we do something like this :
>
> q=status:((46&2)>0) ?
>
>
> --
> View this message in context: http://www.nabble.com/Query-with-bitwise-operation-tp22956950p22956950.html
> Sent from the Solr - User mailing list archive at Nabble.com.