cancel
Showing results for 
Search instead for 
Did you mean: 

Lucene boolean search is broken?

kbryd
Champ in-the-making
Champ in-the-making
Hello

I have been struggling with following issue. I have a type with a boolean property:

<type name="plcy:commission">
   <title>Commission</title>
   <parent>cm:content</parent>
   <properties>
      <property name="plcy:commission_accounted">
         <title>Accounted</title>
         <type>d:boolean</type>
         <default>false</default>
      </property>
      …
      …

Now, when I search with Lucene using a query:

+TYPE:"plcy:commission" AND +@plcy\:commission_accounted:"true"

I get also results which have plcy:commission_accounted set to 'false', I have also tried other queries like:


+TYPE:"plcy:commission" +@plcy\:commission_accounted:"true"
+TYPE:"plcy:commission" +@plcy\:commission_accounted:true
+TYPE:"plcy:commission" AND +(@plcy\:commission_accounted:true)
+@plcy\:commission_accounted:true

etc. and I _always_ get wrong results, for example (node's id, value and the class name of the value):

2e5f8362-6696-4def-9534-9821a49806c2 true class java.lang.Boolean
17dc9fdf-0f92-4444-82f1-944d2a91e17e true class java.lang.Boolean
64bbb631-79aa-4ae9-944e-d5d0c63be064 false class java.lang.Boolean
84ce8e4c-3317-4fc6-a3c8-902f5a5388b3 false class java.lang.Boolean
92b6949e-0db5-4d0a-8972-c90ab248101c false class java.lang.Boolean
6d241b53-5e47-4cb0-a50b-1b9783d3ba19 false class java.lang.Boolean

Funny thing is that when I search for objects with commission_accounted=false I always get correct results. Any ideas what I am doing wrong?

Thanks
Karol
5 REPLIES 5

loftux
Star Contributor
Star Contributor
Having TYPE criteria in you search seem superfluous since your property is only available to that specific type.
Also, AND and the + means the same thing (so in some of your samples queries you have doubled them), see http://wiki.alfresco.com/wiki/Search#Combined_Queries

Maybe using - (must nor match) if only false query works. Then you maybe need to search for TYPE as well, contrary to what I said int the beginning.

kbryd
Champ in-the-making
Champ in-the-making
Having TYPE criteria in you search seem superfluous since your property is only available to that specific type.
Also, AND and the + means the same thing (so in some of your samples queries you have doubled them), see http://wiki.alfresco.com/wiki/Search#Combined_Queries

Maybe using - (must nor match) if only false query works. Then you maybe need to search for TYPE as well, contrary to what I said int the beginning.

You are right about TYPE criteria, however it shouldn't change the result…

Here is a summary of my queries:

Search:   @plcy\:commission_accounted:true
Results 24 rows

(some of those 24 rows contained records with 'false' commission_accounted)

Search:   @plcy\:commission_accounted:false
Results 686 rows

Search:   not @plcy\:commission_accounted:false
Results 686 rows

Search:   -@plcy\:commission_accounted:false
Results 0 rows

Search:   +TYPE:"plcy:commission" AND -@plcy\:commission_accounted:false
Results 24 rows

So the question is still the same: how is it possible? And how to query for records with commission_accounted=true?

loftux
Star Contributor
Star Contributor
Only thing I can think of to try is
+TYPE:"plcy:commission" AND -@plcy\:commission_accounted:true
That should give you all the false ones.

But I agree, this should be doable with only @plcy\:commission_accounted:false, maybe someone else can step in here that has experience of boolean searches.

kbryd
Champ in-the-making
Champ in-the-making
Unfortunately it doesn't work…

Search:    +TYPE:"plcy:commission" AND -@plcy\:commission_accounted:true
Results 0 rows

I will try to report proper bug report about it and in the meantime I will try to change that attribute from boolean to an integer…

Thanks for suggestions!
Karol

mrogers
Star Contributor
Star Contributor
I was working yesterday on very similar query which works correctly.  

+TYPE:"rma:dispositionAction"  +@rma\:dispositionEventsEligible:true
+TYPE:"rma:dispositionAction"  +@rma\:dispositionEventsEligible:false

I've just run it on HEAD and it works, both for the true case and the false case.