Possible bug in TopChildrenQuery

I'm getting this error using the TopChildrenQuery:
ClassCastException[org.elasticsearch.index.search.child.TopChildrenQuery
cannot be cast to org.elasticsearch.index.search.child.HasChildFilter];

Debugging, i found the error to happen in this line:

Which seems weird, why would it convert to HasChildFilter there? Shouldn't
it be casting to TopChildrenQuery?
If it is a bug, i can submit the issue/pull-request fixing.

Thanks.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

I've done few tests.
Changing the casting to TopChildrenQuery did stop the error, but i'm not
sure about side effects, i'll look more into it.

Something also weird is that the .equals() method on XFilteredQuery can
return false when compared with itself.
So, i actually need to change the equals method on TopChildrenQuery
to: TopChildrenQueryEquals.java · GitHub
This is just some experimentations, trying to see any side effect.

On Wednesday, July 3, 2013 10:27:43 AM UTC-3, Rodrigo Ribeiro wrote:

I'm getting this error using the TopChildrenQuery:
ClassCastException[org.elasticsearch.index.search.child.TopChildrenQuery
cannot be cast to org.elasticsearch.index.search.child.HasChildFilter];

Debugging, i found the error to happen in this line:

https://github.com/elasticsearch/elasticsearch/blob/0.90/src/main/java/org/elasticsearch/index/search/child/TopChildrenQuery.java#L264

Which seems weird, why would it convert to HasChildFilter there? Shouldn't
it be casting to TopChildrenQuery?
If it is a bug, i can submit the issue/pull-request fixing.

Thanks.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

That is an epic 'copy-paste' bug... It isn't only TopChildrenQuery, but
also in the ChildrenQuery and ParentQuery classes. I will open an issue
soon and fix this. Thanks for reporting this.

Btw: How are you using the top_children query in your search requests? Are
you wrapping it in a fquery filter?

On 3 July 2013 18:42, Rodrigo Ribeiro rodriguinho@jusbrasil.com.br wrote:

I've done few tests.
Changing the casting to TopChildrenQuery did stop the error, but i'm not
sure about side effects, i'll look more into it.

Something also weird is that the .equals() method on XFilteredQuery can
return false when compared with itself.
So, i actually need to change the equals method on TopChildrenQuery to:
TopChildrenQueryEquals.java · GitHub
This is just some experimentations, trying to see any side effect.

On Wednesday, July 3, 2013 10:27:43 AM UTC-3, Rodrigo Ribeiro wrote:

I'm getting this error using the TopChildrenQuery:
ClassCastException[org.**elasticsearch.index.search.**child.TopChildrenQuery
cannot be cast to org.elasticsearch.index.**search.child.HasChildFilter];

Debugging, i found the error to happen in this line:
https://github.com/**elasticsearch/elasticsearch/**
blob/0.90/src/main/java/org/elasticsearch/index/search/
child/TopChildrenQuery.java#**L264https://github.com/elasticsearch/elasticsearch/blob/0.90/src/main/java/org/elasticsearch/index/search/child/TopChildrenQuery.java#L264

Which seems weird, why would it convert to HasChildFilter there?
Shouldn't it be casting to TopChildrenQuery?
If it is a bug, i can submit the issue/pull-request fixing.

Thanks.

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
Met vriendelijke groet,

Martijn van Groningen

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

I've opened a issue for this:

Also I pushed a fix for it in master and 0.90 branches.

On 3 July 2013 21:30, Martijn v Groningen martijn.v.groningen@gmail.comwrote:

That is an epic 'copy-paste' bug... It isn't only TopChildrenQuery, but
also in the ChildrenQuery and ParentQuery classes. I will open an issue
soon and fix this. Thanks for reporting this.

Btw: How are you using the top_children query in your search requests? Are
you wrapping it in a fquery filter?

On 3 July 2013 18:42, Rodrigo Ribeiro rodriguinho@jusbrasil.com.brwrote:

I've done few tests.
Changing the casting to TopChildrenQuery did stop the error, but i'm not
sure about side effects, i'll look more into it.

Something also weird is that the .equals() method on XFilteredQuery can
return false when compared with itself.
So, i actually need to change the equals method on TopChildrenQuery to:
TopChildrenQueryEquals.java · GitHub
This is just some experimentations, trying to see any side effect.

On Wednesday, July 3, 2013 10:27:43 AM UTC-3, Rodrigo Ribeiro wrote:

I'm getting this error using the TopChildrenQuery:
ClassCastException[org.**elasticsearch.index.search.child.TopChildrenQuery
cannot be cast to org.elasticsearch.index.

search.child.HasChildFilter];

Debugging, i found the error to happen in this line:
https://github.com/**elasticsearch/elasticsearch/**
blob/0.90/src/main/java/org/elasticsearch/index/search/
child/TopChildrenQuery.java#**L264https://github.com/elasticsearch/elasticsearch/blob/0.90/src/main/java/org/elasticsearch/index/search/child/TopChildrenQuery.java#L264

Which seems weird, why would it convert to HasChildFilter there?
Shouldn't it be casting to TopChildrenQuery?
If it is a bug, i can submit the issue/pull-request fixing.

Thanks.

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
Met vriendelijke groet,

Martijn van Groningen

--
Met vriendelijke groet,

Martijn van Groningen

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Thanks Martjn,

The first error was fixed, but now i'm running in another problem, the one
that I mention before about XFilteredQuery.

The following comparison returns false, even originalChildQuery and
that.originalChildQuery being the same instance:

This is a problem for the rewrite() method of the TopChildQuery, cause it
do a indexOf and can't found the query, resulting on
a ArrayIndexOutOfBoundsException later:

This is kinda how i'm using it: https://gist.github.com/rodrigopr/5922742

Thanks again for the quick help.

On Wednesday, July 3, 2013 4:41:47 PM UTC-3, Martijn v Groningen wrote:

I've opened a issue for this:
The top_children, has_child and has_parent query can cause error when cached. · Issue #3290 · elastic/elasticsearch · GitHub
Also I pushed a fix for it in master and 0.90 branches.

On 3 July 2013 21:30, Martijn v Groningen <martijn.v...@gmail.com<javascript:>

wrote:

That is an epic 'copy-paste' bug... It isn't only TopChildrenQuery, but
also in the ChildrenQuery and ParentQuery classes. I will open an issue
soon and fix this. Thanks for reporting this.

Btw: How are you using the top_children query in your search requests?
Are you wrapping it in a fquery filter?

On 3 July 2013 18:42, Rodrigo Ribeiro <rodri...@jusbrasil.com.br<javascript:>

wrote:

I've done few tests.
Changing the casting to TopChildrenQuery did stop the error, but i'm not
sure about side effects, i'll look more into it.

Something also weird is that the .equals() method on XFilteredQuery can
return false when compared with itself.
So, i actually need to change the equals method on TopChildrenQuery to:
TopChildrenQueryEquals.java · GitHub
This is just some experimentations, trying to see any side effect.

On Wednesday, July 3, 2013 10:27:43 AM UTC-3, Rodrigo Ribeiro wrote:

I'm getting this error using the TopChildrenQuery:
ClassCastException[org.**elasticsearch.index.search.child.TopChildrenQuery
cannot be cast to org.elasticsearch.index.

search.child.HasChildFilter];

Debugging, i found the error to happen in this line:
https://github.com/**elasticsearch/elasticsearch/**
blob/0.90/src/main/java/org/elasticsearch/index/search/
child/TopChildrenQuery.java#**L264https://github.com/elasticsearch/elasticsearch/blob/0.90/src/main/java/org/elasticsearch/index/search/child/TopChildrenQuery.java#L264

Which seems weird, why would it convert to HasChildFilter there?
Shouldn't it be casting to TopChildrenQuery?
If it is a bug, i can submit the issue/pull-request fixing.

Thanks.

--
You received this message because you are subscribed to the Google
Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to elasticsearc...@googlegroups.com <javascript:>.
For more options, visit https://groups.google.com/groups/opt_out.

--
Met vriendelijke groet,

Martijn van Groningen

--
Met vriendelijke groet,

Martijn van Groningen

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

I think that the following code in TopChildrenQuery#equals() is correct:
TopChildrenQuery that = (TopChildrenQuery) obj;
if (!originalChildQuery.equals(that.originalChildQuery)) {
return false;
}

All Query impl should have the following code, that returns in the case the
instance is the same:
if (this == obj) {
return true;
}

So I wouldn't expect that TopChildrenQuery#equals method to be a problem.
What query are you wrapping in the top_children query in your gist?

On 3 July 2013 23:06, Rodrigo Ribeiro rodriguinho@jusbrasil.com.br wrote:

Thanks Martjn,

The first error was fixed, but now i'm running in another problem, the one
that I mention before about XFilteredQuery.

The following comparison returns false, even originalChildQuery and
that.originalChildQuery being the same instance:

https://github.com/elasticsearch/elasticsearch/blob/0.90/src/main/java/org/elasticsearch/index/search/child/TopChildrenQuery.java#L265

This is a problem for the rewrite() method of the TopChildQuery, cause it
do a indexOf and can't found the query, resulting on
a ArrayIndexOutOfBoundsException later:

https://github.com/elasticsearch/elasticsearch/blob/0.90/src/main/java/org/elasticsearch/index/search/child/TopChildrenQuery.java#L116

This is kinda how i'm using it: https://gist.github.com/rodrigopr/5922742

Thanks again for the quick help.

On Wednesday, July 3, 2013 4:41:47 PM UTC-3, Martijn v Groningen wrote:

I've opened a issue for this: https://github.com/**
elasticsearch/elasticsearch/**issues/3290https://github.com/elasticsearch/elasticsearch/issues/3290
Also I pushed a fix for it in master and 0.90 branches.

On 3 July 2013 21:30, Martijn v Groningen <martijn.v...@gmail.com**>wrote:

That is an epic 'copy-paste' bug... It isn't only TopChildrenQuery, but
also in the ChildrenQuery and ParentQuery classes. I will open an issue
soon and fix this. Thanks for reporting this.

Btw: How are you using the top_children query in your search requests?
Are you wrapping it in a fquery filter?

On 3 July 2013 18:42, Rodrigo Ribeiro rodri...@jusbrasil.com.br wrote:

I've done few tests.
Changing the casting to TopChildrenQuery did stop the error, but i'm
not sure about side effects, i'll look more into it.

Something also weird is that the .equals() method on XFilteredQuery can
return false when compared with itself.
So, i actually need to change the equals method on TopChildrenQuery to:
https://gist.github.com/**rodrigopr/5920278https://gist.github.com/rodrigopr/5920278
This is just some experimentations, trying to see any side effect.

On Wednesday, July 3, 2013 10:27:43 AM UTC-3, Rodrigo Ribeiro wrote:

I'm getting this error using the TopChildrenQuery:
ClassCastException[org.elasticsearch.index.search.**child.**TopChildrenQuery
cannot be cast to org.elasticsearch.index.search
.child.HasChildFilter];

Debugging, i found the error to happen in this line:
https://github.com/**elasticsear**ch/elasticsearch/**blob/0.90/**
src/main/java/org/elasticsearch/index/search/child/
TopChildrenQuery.java#**L264https://github.com/elasticsearch/elasticsearch/blob/0.90/src/main/java/org/elasticsearch/index/search/child/TopChildrenQuery.java#L264

Which seems weird, why would it convert to HasChildFilter there?
Shouldn't it be casting to TopChildrenQuery?
If it is a bug, i can submit the issue/pull-request fixing.

Thanks.

--
You received this message because you are subscribed to the Google
Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to elasticsearc...@**googlegroups.com.

For more options, visit https://groups.google.com/**groups/opt_outhttps://groups.google.com/groups/opt_out
.

--
Met vriendelijke groet,

Martijn van Groningen

--
Met vriendelijke groet,

Martijn van Groningen

--
Met vriendelijke groet,

Martijn van Groningen

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

I agree with you about the TopChildrenQuery#equals method.

I think the problem is actually on:
https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/common/lucene/search/XFilteredQuery.java#L162

Cause xFilteredQueryInstance.equals(xFilteredQueryInstance) can return
false.

This is how we are using the top_children:
https://gist.github.com/rodrigopr/5928134

On Thursday, July 4, 2013 7:31:26 AM UTC-3, Martijn v Groningen wrote:

I think that the following code in TopChildrenQuery#equals() is correct:
TopChildrenQuery that = (TopChildrenQuery) obj;
if (!originalChildQuery.equals(that.originalChildQuery)) {
return false;
}

All Query impl should have the following code, that returns in the case
the instance is the same:
if (this == obj) {
return true;
}

So I wouldn't expect that TopChildrenQuery#equals method to be a problem.
What query are you wrapping in the top_children query in your gist?

On 3 July 2013 23:06, Rodrigo Ribeiro <rodri...@jusbrasil.com.br<javascript:>

wrote:

Thanks Martjn,

The first error was fixed, but now i'm running in another problem, the
one that I mention before about XFilteredQuery.

The following comparison returns false, even originalChildQuery and
that.originalChildQuery being the same instance:

https://github.com/elasticsearch/elasticsearch/blob/0.90/src/main/java/org/elasticsearch/index/search/child/TopChildrenQuery.java#L265

This is a problem for the rewrite() method of the TopChildQuery, cause it
do a indexOf and can't found the query, resulting on
a ArrayIndexOutOfBoundsException later:

https://github.com/elasticsearch/elasticsearch/blob/0.90/src/main/java/org/elasticsearch/index/search/child/TopChildrenQuery.java#L116

This is kinda how i'm using it: https://gist.github.com/rodrigopr/5922742

Thanks again for the quick help.

On Wednesday, July 3, 2013 4:41:47 PM UTC-3, Martijn v Groningen wrote:

I've opened a issue for this: https://github.com/**
elasticsearch/elasticsearch/**issues/3290https://github.com/elasticsearch/elasticsearch/issues/3290
Also I pushed a fix for it in master and 0.90 branches.

On 3 July 2013 21:30, Martijn v Groningen <martijn.v...@gmail.com**>wrote:

That is an epic 'copy-paste' bug... It isn't only TopChildrenQuery, but
also in the ChildrenQuery and ParentQuery classes. I will open an issue
soon and fix this. Thanks for reporting this.

Btw: How are you using the top_children query in your search requests?
Are you wrapping it in a fquery filter?

On 3 July 2013 18:42, Rodrigo Ribeiro rodri...@jusbrasil.com.brwrote:

I've done few tests.
Changing the casting to TopChildrenQuery did stop the error, but i'm
not sure about side effects, i'll look more into it.

Something also weird is that the .equals() method on XFilteredQuery
can return false when compared with itself.
So, i actually need to change the equals method on TopChildrenQuery
to: https://gist.github.com/**rodrigopr/5920278https://gist.github.com/rodrigopr/5920278
This is just some experimentations, trying to see any side effect.

On Wednesday, July 3, 2013 10:27:43 AM UTC-3, Rodrigo Ribeiro wrote:

I'm getting this error using the TopChildrenQuery:
ClassCastException[org.elasticsearch.index.search.**child.**TopChildrenQuery
cannot be cast to org.elasticsearch.index.search
.child.HasChildFilter];

Debugging, i found the error to happen in this line:
https://github.com/**elasticsear**ch/elasticsearch/**blob/0.90/**
src/main/java/org/elasticsearch/index/search/child/
TopChildrenQuery.java#**L264https://github.com/elasticsearch/elasticsearch/blob/0.90/src/main/java/org/elasticsearch/index/search/child/TopChildrenQuery.java#L264

Which seems weird, why would it convert to HasChildFilter there?
Shouldn't it be casting to TopChildrenQuery?
If it is a bug, i can submit the issue/pull-request fixing.

Thanks.

--
You received this message because you are subscribed to the Google
Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to elasticsearc...@**googlegroups.com.

For more options, visit https://groups.google.com/**groups/opt_outhttps://groups.google.com/groups/opt_out
.

--
Met vriendelijke groet,

Martijn van Groningen

--
Met vriendelijke groet,

Martijn van Groningen

--
Met vriendelijke groet,

Martijn van Groningen

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

I don't think that the XFilteredQuery#equals method is a problem, since it
delegates all calls to FilteredQuery#equals (delegate).
I assume that you are using search_type with option
dfs_query_then_fetch, right?
Also what elasticsearch version are you using?

On 4 July 2013 16:15, Rodrigo Ribeiro rodriguinho@jusbrasil.com.br wrote:

I agree with you about the TopChildrenQuery#equals method.

I think the problem is actually on:

https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/common/lucene/search/XFilteredQuery.java#L162

Cause xFilteredQueryInstance.equals(xFilteredQueryInstance) can return
false.

This is how we are using the top_children:
https://gist.github.com/rodrigopr/5928134

On Thursday, July 4, 2013 7:31:26 AM UTC-3, Martijn v Groningen wrote:

I think that the following code in TopChildrenQuery#equals() is correct:
TopChildrenQuery that = (TopChildrenQuery) obj;
if (!originalChildQuery.equals(**that.originalChildQuery)) {
return false;
}

All Query impl should have the following code, that returns in the case
the instance is the same:
if (this == obj) {
return true;
}

So I wouldn't expect that TopChildrenQuery#equals method to be a problem.
What query are you wrapping in the top_children query in your gist?

On 3 July 2013 23:06, Rodrigo Ribeiro rodri...@jusbrasil.com.br wrote:

Thanks Martjn,

The first error was fixed, but now i'm running in another problem, the
one that I mention before about XFilteredQuery.

The following comparison returns false, even originalChildQuery and
that.originalChildQuery being the same instance:
https://github.com/**elasticsearch/elasticsearch/**
blob/0.90/src/main/java/org/elasticsearch/index/search/
child/TopChildrenQuery.java#**L265https://github.com/elasticsearch/elasticsearch/blob/0.90/src/main/java/org/elasticsearch/index/search/child/TopChildrenQuery.java#L265

This is a problem for the rewrite() method of the TopChildQuery, cause
it do a indexOf and can't found the query, resulting on a ArrayIndexOutOfBoundsException
later:
https://github.com/**elasticsearch/elasticsearch/

blob/0.90/src/main/java/org/elasticsearch/index/search/
child/TopChildrenQuery.java#**L116https://github.com/elasticsearch/elasticsearch/blob/0.90/src/main/java/org/elasticsearch/index/search/child/TopChildrenQuery.java#L116

This is kinda how i'm using it: https://gist.github.com/**
rodrigopr/5922742 https://gist.github.com/rodrigopr/5922742

Thanks again for the quick help.

On Wednesday, July 3, 2013 4:41:47 PM UTC-3, Martijn v Groningen wrote:

I've opened a issue for this: https://github.com/**elast**
icsearch/elasticsearch/**issues/**3290https://github.com/elasticsearch/elasticsearch/issues/3290
Also I pushed a fix for it in master and 0.90 branches.

On 3 July 2013 21:30, Martijn v Groningen <martijn.v...@gmail.com**>wrote:

That is an epic 'copy-paste' bug... It isn't only TopChildrenQuery,
but also in the ChildrenQuery and ParentQuery classes. I will open an issue
soon and fix this. Thanks for reporting this.

Btw: How are you using the top_children query in your search requests?
Are you wrapping it in a fquery filter?

On 3 July 2013 18:42, Rodrigo Ribeiro rodri...@jusbrasil.com.brwrote:

I've done few tests.
Changing the casting to TopChildrenQuery did stop the error, but i'm
not sure about side effects, i'll look more into it.

Something also weird is that the .equals() method on XFilteredQuery
can return false when compared with itself.
So, i actually need to change the equals method on TopChildrenQuery
to: https://gist.github.com/**ro**drigopr/5920278https://gist.github.com/rodrigopr/5920278
This is just some experimentations, trying to see any side effect.

On Wednesday, July 3, 2013 10:27:43 AM UTC-3, Rodrigo Ribeiro wrote:

I'm getting this error using the TopChildrenQuery:
ClassCastException[org.elastic****search.index.search.child.
TopC
hildrenQuery cannot be cast to org.elasticsearch.index.**
search****.child.HasChildFilter];

Debugging, i found the error to happen in this line:
https://github.com/**elasticsear****ch/elasticsearch/**blob/0.90/**
src**/main/java/org/elasticsearch/index/search/child/
TopChildren
Query.java#**L264https://github.com/elasticsearch/elasticsearch/blob/0.90/src/main/java/org/elasticsearch/index/search/child/TopChildrenQuery.java#L264

Which seems weird, why would it convert to HasChildFilter there?
Shouldn't it be casting to TopChildrenQuery?
If it is a bug, i can submit the issue/pull-request fixing.

Thanks.

--
You received this message because you are subscribed to the Google
Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it,
send an email to elasticsearc...@**googlegroups.**com.

For more options, visit https://groups.google.com/**grou**ps/opt_outhttps://groups.google.com/groups/opt_out
.

--
Met vriendelijke groet,

Martijn van Groningen

--
Met vriendelijke groet,

Martijn van Groningen

--
Met vriendelijke groet,

Martijn van Groningen

--
Met vriendelijke groet,

Martijn van Groningen

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Yes, i'm using dfs_query_then_fetch.
Now that you mention, i tried with just query_then_fetch, and it
works(maybe it is not caching something)

I'm using 0.90.1.

I did mention the equals cause the delegate was a instance
of org.apache.lucene.search.FilteredQuery, and was being compared with
a XFilteredQuery object.
The comparison failed on an if (getClass() != obj.getClass()) check from
org.apache.lucene.search.Query#equals

Thanks for your help so far mate.

On Thursday, July 4, 2013 1:28:59 PM UTC-3, Martijn v Groningen wrote:

I don't think that the XFilteredQuery#equals method is a problem, since it
delegates all calls to FilteredQuery#equals (delegate).
I assume that you are using search_type with option
dfs_query_then_fetch, right?
Also what elasticsearch version are you using?

On 4 July 2013 16:15, Rodrigo Ribeiro <rodri...@jusbrasil.com.br<javascript:>

wrote:

I agree with you about the TopChildrenQuery#equals method.

I think the problem is actually on:

https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/common/lucene/search/XFilteredQuery.java#L162

Cause xFilteredQueryInstance.equals(xFilteredQueryInstance) can return
false.

This is how we are using the top_children:
https://gist.github.com/rodrigopr/5928134

On Thursday, July 4, 2013 7:31:26 AM UTC-3, Martijn v Groningen wrote:

I think that the following code in TopChildrenQuery#equals() is correct:
TopChildrenQuery that = (TopChildrenQuery) obj;
if (!originalChildQuery.equals(**that.originalChildQuery)) {
return false;
}

All Query impl should have the following code, that returns in the case
the instance is the same:
if (this == obj) {
return true;
}

So I wouldn't expect that TopChildrenQuery#equals method to be a
problem. What query are you wrapping in the top_children query in your gist?

On 3 July 2013 23:06, Rodrigo Ribeiro rodri...@jusbrasil.com.br wrote:

Thanks Martjn,

The first error was fixed, but now i'm running in another problem, the
one that I mention before about XFilteredQuery.

The following comparison returns false, even originalChildQuery and
that.originalChildQuery being the same instance:
https://github.com/**elasticsearch/elasticsearch/**
blob/0.90/src/main/java/org/elasticsearch/index/search/
child/TopChildrenQuery.java#**L265https://github.com/elasticsearch/elasticsearch/blob/0.90/src/main/java/org/elasticsearch/index/search/child/TopChildrenQuery.java#L265

This is a problem for the rewrite() method of the TopChildQuery, cause
it do a indexOf and can't found the query, resulting on a ArrayIndexOutOfBoundsException
later:
https://github.com/**elasticsearch/elasticsearch/

blob/0.90/src/main/java/org/elasticsearch/index/search/
child/TopChildrenQuery.java#**L116https://github.com/elasticsearch/elasticsearch/blob/0.90/src/main/java/org/elasticsearch/index/search/child/TopChildrenQuery.java#L116

This is kinda how i'm using it: https://gist.github.com/**
rodrigopr/5922742 https://gist.github.com/rodrigopr/5922742

Thanks again for the quick help.

On Wednesday, July 3, 2013 4:41:47 PM UTC-3, Martijn v Groningen wrote:

I've opened a issue for this: https://github.com/**elast**
icsearch/elasticsearch/**issues/**3290https://github.com/elasticsearch/elasticsearch/issues/3290
Also I pushed a fix for it in master and 0.90 branches.

On 3 July 2013 21:30, Martijn v Groningen <martijn.v...@gmail.com**>wrote:

That is an epic 'copy-paste' bug... It isn't only TopChildrenQuery,
but also in the ChildrenQuery and ParentQuery classes. I will open an issue
soon and fix this. Thanks for reporting this.

Btw: How are you using the top_children query in your search
requests? Are you wrapping it in a fquery filter?

On 3 July 2013 18:42, Rodrigo Ribeiro rodri...@jusbrasil.com.brwrote:

I've done few tests.
Changing the casting to TopChildrenQuery did stop the error, but i'm
not sure about side effects, i'll look more into it.

Something also weird is that the .equals() method on XFilteredQuery
can return false when compared with itself.
So, i actually need to change the equals method on TopChildrenQuery
to: https://gist.github.com/**ro**drigopr/5920278https://gist.github.com/rodrigopr/5920278
This is just some experimentations, trying to see any side effect.

On Wednesday, July 3, 2013 10:27:43 AM UTC-3, Rodrigo Ribeiro wrote:

I'm getting this error using the TopChildrenQuery:
ClassCastException[org.elastic****search.index.search.child.
TopC
hildrenQuery cannot be cast to org.elasticsearch.index.**
search****.child.HasChildFilter];

Debugging, i found the error to happen in this line:
https://github.com/**elasticsear****ch/elasticsearch/**blob/0.90/**
src**/main/java/org/elasticsearch/index/search/child/
TopChildren
Query.java#**L264https://github.com/elasticsearch/elasticsearch/blob/0.90/src/main/java/org/elasticsearch/index/search/child/TopChildrenQuery.java#L264

Which seems weird, why would it convert to HasChildFilter there?
Shouldn't it be casting to TopChildrenQuery?
If it is a bug, i can submit the issue/pull-request fixing.

Thanks.

--
You received this message because you are subscribed to the Google
Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it,
send an email to elasticsearc...@**googlegroups.**com.

For more options, visit https://groups.google.com/**grou**ps/opt_outhttps://groups.google.com/groups/opt_out
.

--
Met vriendelijke groet,

Martijn van Groningen

--
Met vriendelijke groet,

Martijn van Groningen

--
Met vriendelijke groet,

Martijn van Groningen

--
Met vriendelijke groet,

Martijn van Groningen

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

This seems like a bug (with the dfs_* search type). I suspect that the
query rewrite is causing this. The TopChildrenQuery#rewrite method looks
wrong. This part:
if (rewritten == rewrittenChildQuery) {
return this;
}

I haven't been able to reproduce the error that you've encountered, but I
will update the TopChildrenQuery#rewrite method.

On 4 July 2013 18:37, Rodrigo Ribeiro rodriguinho@jusbrasil.com.br wrote:

Yes, i'm using dfs_query_then_fetch.
Now that you mention, i tried with just query_then_fetch, and it
works(maybe it is not caching something)

I'm using 0.90.1.

I did mention the equals cause the delegate was a instance
of org.apache.lucene.search.FilteredQuery, and was being compared with
a XFilteredQuery object.
The comparison failed on an if (getClass() != obj.getClass()) check from
org.apache.lucene.search.Query#equals

Thanks for your help so far mate.

On Thursday, July 4, 2013 1:28:59 PM UTC-3, Martijn v Groningen wrote:

I don't think that the XFilteredQuery#equals method is a problem, since
it delegates all calls to FilteredQuery#equals (delegate).
I assume that you are using search_type with option
dfs_query_then_fetch, right?
Also what elasticsearch version are you using?

On 4 July 2013 16:15, Rodrigo Ribeiro rodri...@jusbrasil.com.br wrote:

I agree with you about the TopChildrenQuery#equals method.

I think the problem is actually on:
https://github.com/**elasticsearch/elasticsearch/**
blob/master/src/main/java/org/elasticsearch/common/lucene/
search/XFilteredQuery.java#**L162https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/common/lucene/search/XFilteredQuery.java#L162

Cause xFilteredQueryInstance.**equals(xFilteredQueryInstance)** can
return false.

This is how we are using the top_children: https://gist.**
github.com/rodrigopr/5928134 https://gist.github.com/rodrigopr/5928134

On Thursday, July 4, 2013 7:31:26 AM UTC-3, Martijn v Groningen wrote:

I think that the following code in TopChildrenQuery#equals() is correct:
TopChildrenQuery that = (TopChildrenQuery) obj;
if (!originalChildQuery.equals(that.originalChildQuery)) {
return false;
}

All Query impl should have the following code, that returns in the case
the instance is the same:
if (this == obj) {
return true;
}

So I wouldn't expect that TopChildrenQuery#equals method to be a
problem. What query are you wrapping in the top_children query in your gist?

On 3 July 2013 23:06, Rodrigo Ribeiro rodri...@jusbrasil.com.brwrote:

Thanks Martjn,

The first error was fixed, but now i'm running in another problem, the
one that I mention before about XFilteredQuery.

The following comparison returns false, even originalChildQuery and
that.originalChildQuery being the same instance:
https://github.com/**elasticsear**ch/elasticsearch/**blob/0.90/**
src/main/java/org/elasticsearch/index/search/child/
TopChildrenQuery.java#**L265https://github.com/elasticsearch/elasticsearch/blob/0.90/src/main/java/org/elasticsearch/index/search/child/TopChildrenQuery.java#L265

This is a problem for the rewrite() method of the TopChildQuery, cause
it do a indexOf and can't found the query, resulting on a **
ArrayIndexOutOfBoundsException later:
https://github.com/**elasticsear**ch/elasticsearch/**blob/0.90/

src/main/java/org/elasticsearch/index/search/child/
TopChildrenQuery.java#**L116https://github.com/elasticsearch/elasticsearch/blob/0.90/src/main/java/org/elasticsearch/index/search/child/TopChildrenQuery.java#L116

This is kinda how i'm using it: https://gist.github.com/**rodrig**
opr/5922742 https://gist.github.com/rodrigopr/5922742

Thanks again for the quick help.

On Wednesday, July 3, 2013 4:41:47 PM UTC-3, Martijn v Groningen wrote:

I've opened a issue for this: https://github.com/**elast****
icsearch/elasticsearch/**issues/****3290https://github.com/elasticsearch/elasticsearch/issues/3290
Also I pushed a fix for it in master and 0.90 branches.

On 3 July 2013 21:30, Martijn v Groningen <martijn.v...@gmail.com**>wrote:

That is an epic 'copy-paste' bug... It isn't only TopChildrenQuery,
but also in the ChildrenQuery and ParentQuery classes. I will open an issue
soon and fix this. Thanks for reporting this.

Btw: How are you using the top_children query in your search
requests? Are you wrapping it in a fquery filter?

On 3 July 2013 18:42, Rodrigo Ribeiro rodri...@jusbrasil.com.brwrote:

I've done few tests.
Changing the casting to TopChildrenQuery did stop the error, but
i'm not sure about side effects, i'll look more into it.

Something also weird is that the .equals() method on XFilteredQuery
can return false when compared with itself.
So, i actually need to change the equals method on TopChildrenQuery
to: https://gist.github.com/**ro****drigopr/5920278https://gist.github.com/rodrigopr/5920278
This is just some experimentations, trying to see any side effect.

On Wednesday, July 3, 2013 10:27:43 AM UTC-3, Rodrigo Ribeiro wrote:

I'm getting this error using the TopChildrenQuery:
ClassCastException[org.elasticsearch.index.search.**child.
**TopC
hildrenQuery cannot be cast to org.elasticsearch.index.*
search*****.child.HasChildFilter];

Debugging, i found the error to happen in this line:
https://github.com/**elasticsear******ch/elasticsearch/**
blob/0.90/src**/main/java/org/elasticsearch/i
ndex/search/child/TopChildrenQuery.java#**L264https://github.com/elasticsearch/elasticsearch/blob/0.90/src/main/java/org/elasticsearch/index/search/child/TopChildrenQuery.java#L264

Which seems weird, why would it convert to HasChildFilter there?
Shouldn't it be casting to TopChildrenQuery?
If it is a bug, i can submit the issue/pull-request fixing.

Thanks.

--
You received this message because you are subscribed to the Google
Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it,
send an email to elasticsearc...@**googlegroups.com.

For more options, visit https://groups.google.com/**grou****
ps/opt_out https://groups.google.com/groups/opt_out.

--
Met vriendelijke groet,

Martijn van Groningen

--
Met vriendelijke groet,

Martijn van Groningen

--
Met vriendelijke groet,

Martijn van Groningen

--
Met vriendelijke groet,

Martijn van Groningen

--
Met vriendelijke groet,

Martijn van Groningen

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.