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 Steven White <sw...@gmail.com> on 2015/06/03 23:38:00 UTC

BoolField fieldType

Hi everyone,

This is a two part question:

1) I see the following: <fieldType name="boolean" class="solr.BoolField"
sortMissingLast="true"/>

a) what does sortMissingLast do?
b) what kind of data is considered Boolean?  "TRUE", "True", "true", "1",
"yes,", "Yes, "FALSE", etc.

2) When searching, what do I search on: q=MyBoolField:<what>  That is what
should "<what>" be?

Thanks

Steve

Re: BoolField fieldType

Posted by Chris Hostetter <ho...@fucit.org>.
: I took a quick look at the code and it _looks_ like any string
: starting with "t", "T" or "1" is evaluated as true and everything else
: as false.

correct and documented...
https://cwiki.apache.org/confluence/display/solr/Field+Types+Included+with+Solr

: sortMissingLast determines sort order if you're sorting on this field
: and the document doesn't have a value. Should the be sorted after or
: before docs that have a value for the field?

also correct and documented...
https://cwiki.apache.org/confluence/display/solr/Field+Type+Definitions+and+Properties


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

Re: BoolField fieldType

Posted by Steven White <sw...@gmail.com>.
Thank you all for helping and updating the doc.  As always, it is greatly
appreciated.

Steve

On Thu, Jun 4, 2015 at 1:53 PM, Chris Hostetter <ho...@fucit.org>
wrote:

>
> : What about at query time?  If I index my Boolean and it has one of the
> : variations of "t", "T" or "1", what should my query be to get a hit on
> : "true"?  q=MyBoolField:<what> ?  What should the value of <what> be when
> I
> : want to check if the field has a "true" and when I need to check if it
> has
> : a "false"?
>
> the string representations are parsed into the logical concepts -- it
> doesn't matter if one doc was added with a value of "true" and another doc
> was indexed with a value of "T" in the index they both have a true value.
>
> likewise at query time it doesn't matter if you query for "true" or "T" -
> they are both going to find all docs that have a true value, and querying
> for "F" or "false" or "BOGUS" are going to find you all docs with a false
> value.
>
> where things get interesting is is when you deal with documents that do
> not have a value in the field at all -- searching for something like
> this...
>
>         q=-MyBoolField:true
>
> ...won't just return all the docs with a false value, it will also return
> all docs w/o any value.
>
> if you want to find all documents that don't have any value, you can
> search for this...
>
>         q=-MyBoolField:*
>
> note that the "*" is a query parser feature, so it causes the query parser
> to do a "docs with value in this field" query w/o ever asking the
> BoolField to "parse" the input string as a true/false value.
>
>
>
> -Hoss
> http://www.lucidworks.com/
>

Re: BoolField fieldType

Posted by Chris Hostetter <ho...@fucit.org>.
: What about at query time?  If I index my Boolean and it has one of the
: variations of "t", "T" or "1", what should my query be to get a hit on
: "true"?  q=MyBoolField:<what> ?  What should the value of <what> be when I
: want to check if the field has a "true" and when I need to check if it has
: a "false"?

the string representations are parsed into the logical concepts -- it 
doesn't matter if one doc was added with a value of "true" and another doc 
was indexed with a value of "T" in the index they both have a true value.

likewise at query time it doesn't matter if you query for "true" or "T" - 
they are both going to find all docs that have a true value, and querying 
for "F" or "false" or "BOGUS" are going to find you all docs with a false 
value.

where things get interesting is is when you deal with documents that do 
not have a value in the field at all -- searching for something like 
this...

	q=-MyBoolField:true

...won't just return all the docs with a false value, it will also return 
all docs w/o any value.

if you want to find all documents that don't have any value, you can 
search for this...

	q=-MyBoolField:*

note that the "*" is a query parser feature, so it causes the query parser 
to do a "docs with value in this field" query w/o ever asking the 
BoolField to "parse" the input string as a true/false value.



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

Re: BoolField fieldType

Posted by Erick Erickson <er...@gmail.com>.
Have you tried it? Really, it should take you 2 minutes to add a doc and see.

I'd guess it follows the same rules.

Best,
Erick

On Thu, Jun 4, 2015 at 5:29 AM, Steven White <sw...@gmail.com> wrote:
> Thanks Erick.
>
> What about at query time?  If I index my Boolean and it has one of the
> variations of "t", "T" or "1", what should my query be to get a hit on
> "true"?  q=MyBoolField:<what> ?  What should the value of <what> be when I
> want to check if the field has a "true" and when I need to check if it has
> a "false"?
>
> Steve
>
> On Wed, Jun 3, 2015 at 6:41 PM, Erick Erickson <er...@gmail.com>
> wrote:
>
>> I took a quick look at the code and it _looks_ like any string
>> starting with "t", "T" or "1" is evaluated as true and everything else
>> as false.
>>
>> sortMissingLast determines sort order if you're sorting on this field
>> and the document doesn't have a value. Should the be sorted after or
>> before docs that have a value for the field?
>>
>> Hmm, could use some better docs....
>>
>> Erick
>>
>> On Wed, Jun 3, 2015 at 2:38 PM, Steven White <sw...@gmail.com> wrote:
>> > Hi everyone,
>> >
>> > This is a two part question:
>> >
>> > 1) I see the following: <fieldType name="boolean" class="solr.BoolField"
>> > sortMissingLast="true"/>
>> >
>> > a) what does sortMissingLast do?
>> > b) what kind of data is considered Boolean?  "TRUE", "True", "true", "1",
>> > "yes,", "Yes, "FALSE", etc.
>> >
>> > 2) When searching, what do I search on: q=MyBoolField:<what>  That is
>> what
>> > should "<what>" be?
>> >
>> > Thanks
>> >
>> > Steve
>>

Re: BoolField fieldType

Posted by Steven White <sw...@gmail.com>.
Thanks Erick.

What about at query time?  If I index my Boolean and it has one of the
variations of "t", "T" or "1", what should my query be to get a hit on
"true"?  q=MyBoolField:<what> ?  What should the value of <what> be when I
want to check if the field has a "true" and when I need to check if it has
a "false"?

Steve

On Wed, Jun 3, 2015 at 6:41 PM, Erick Erickson <er...@gmail.com>
wrote:

> I took a quick look at the code and it _looks_ like any string
> starting with "t", "T" or "1" is evaluated as true and everything else
> as false.
>
> sortMissingLast determines sort order if you're sorting on this field
> and the document doesn't have a value. Should the be sorted after or
> before docs that have a value for the field?
>
> Hmm, could use some better docs....
>
> Erick
>
> On Wed, Jun 3, 2015 at 2:38 PM, Steven White <sw...@gmail.com> wrote:
> > Hi everyone,
> >
> > This is a two part question:
> >
> > 1) I see the following: <fieldType name="boolean" class="solr.BoolField"
> > sortMissingLast="true"/>
> >
> > a) what does sortMissingLast do?
> > b) what kind of data is considered Boolean?  "TRUE", "True", "true", "1",
> > "yes,", "Yes, "FALSE", etc.
> >
> > 2) When searching, what do I search on: q=MyBoolField:<what>  That is
> what
> > should "<what>" be?
> >
> > Thanks
> >
> > Steve
>

Re: BoolField fieldType

Posted by Erick Erickson <er...@gmail.com>.
I took a quick look at the code and it _looks_ like any string
starting with "t", "T" or "1" is evaluated as true and everything else
as false.

sortMissingLast determines sort order if you're sorting on this field
and the document doesn't have a value. Should the be sorted after or
before docs that have a value for the field?

Hmm, could use some better docs....

Erick

On Wed, Jun 3, 2015 at 2:38 PM, Steven White <sw...@gmail.com> wrote:
> Hi everyone,
>
> This is a two part question:
>
> 1) I see the following: <fieldType name="boolean" class="solr.BoolField"
> sortMissingLast="true"/>
>
> a) what does sortMissingLast do?
> b) what kind of data is considered Boolean?  "TRUE", "True", "true", "1",
> "yes,", "Yes, "FALSE", etc.
>
> 2) When searching, what do I search on: q=MyBoolField:<what>  That is what
> should "<what>" be?
>
> Thanks
>
> Steve