-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Unexpected behaviour MustJunction
PostPosted: Tue Apr 03, 2012 12:32 pm 
Pro
Pro

Joined: Wed Nov 05, 2003 7:22 pm
Posts: 211
Hi,

I have a MustJunction that is not doing what I think it should
Let's say we want to select a bunch of documents based on ids.
AFAIK, the following way would be the way to do it.

Code:
BooleanJunction sj = qb.bool();
      
for(String id : ids){
   sj = sj.should(
      qb.keyword().onField("id").matching(id).createQuery()
   );
}

Query q = mj.bool().must(
     sj.createQuery()
).createQuery();


I would expect Query q to be: +(id:1 id:2 id:3)
However, it is: id:1 id:2 id:3
Returning all records

When I add the following, everything works as expected:

Code:
BooleanJunction sj = qb.bool();
      
for(String id : ids){
   sj = sj.should(
      qb.keyword().onField("id").matching(id).createQuery()
   );
}

MustJunction mj = qb.bool().must(sj.createQuery());
Query q = mj.must(
   qb.keyword().onField("abc").matching("true").createQuery()
).must(
   sj.createQuery()
).createQuery();



Query q to be: +(id:1 id:2 id:3) +abc:true

Even though it can be argued that a MustJunction should at least contain two queries, I think this should be considered a bug. Unless, there is a different way to achieve what I want.

Kind regards,
Marc


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.