New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Alias with filter is not reliable #10135
Comments
Hi @mikiot can you please post a complete curl recreation of the issue you are facing so we can have a look at what's causing it? |
I add the following documents to it
Then I create the index alias
Performing a simple query like GET esbug_123/_search produces inconsistent results. |
Hi @mikiot I'm having troubles parsing your alias request, the filter doesn't fit in my screen :) Did you try to trim it down a bit and see which part is causing the problem that you see exactly? Did you try executing the flter by itself, without going through the alias? |
What do you mean by it does not fit in the screen?
|
sorry @mikiot about the irony, I just meant that the filter is very big and hard to read. Much better now, thanks a lot for trimming it down. I managed to reproduce the problem, it does seem like a bug. @martijnvg can you have a look please? here is the stacktrace (ran from current 1.x), seems like
|
@javanna You know you can always use a json formatter like this one https://www.jsoneditoronline.org/ for big jsons. This is what I used to remove the indentation. ;) |
@mikiot I know and I spent some time doing it yesterday but somehow elasticsearch would refuse that filter although the json seemed valid, now it's better, thanks again |
Talked with @martijnvg (parent-child wizard) and he says that has_child & has_parent don't work properly as part of alias filters and percolator. There is no currently way to support them properly, thus we are leaning towards rejecting them completely when presented as part of alias filters or percolator queries. |
+1 to reject p/c filters from aliases for now. One issue with those filters is that the set of documents that match on a segment also depends on data that are stored in other segments because of the join. However, filters work per segment and it is expected that they always produce the same set of matches per segment (otherwise we could never cache). This does not work for p/c queries. We have some hacks in place to make sure when using p/c filters that they are never cached (NoCacheFilter) and that the join is performed only once (the horrible CustomQueryWrappingFilter) but it does not work with aliases which enforce caching. We might have opportunities to make it better in 2.x with the queries/filter merge, but that would still be a lot of work and until then it is probably wiser to just reject such filters instead of adding on the existing hacks. |
What I realized was that the actually issue here with I think the only sane thing to do here is to prohibit the use of p/c filters in index aliases. Also when #8134 gets fixed then p/c filters can no longer be used in index aliases. |
So you say it is impossible to be fixed for now? Should I find another solution for problem? |
@mikiot Sadly yes. A work-around is to provide the parent/child filter on every query execution instead of relying on the alias. |
If alias filter were parsed at search time instead of alias creation time then this problem wouldn't exist. Maybe for certain alias filter this would make sense? Also this not so nice work around can be removed: #8534 |
@martijnvg ++ on parsing alias filters on search time each time, its cheap and safer |
Closing in favour of #10485 |
I am using elasticsearch 1.4.4 and I want to create a filtered alias.
The index contains 3 types A, B and C. B and C are children to A. The filter extracts from the index all the types applying some conditions.For one of the types (let set it's A) the filter contains a nested and a has_child filter.
The alias gets created and works fine until I try to update the filter. I need to update the filter because
some entities are soft deleted, but the alias should not return them. In this case the filter changes to something like extract all documents with type A where B deleted date > some date.
After I update the filter and try to query for A with a simple search it sometimes return all A (applying the filter) and sometimes it returns only some of the documents, excluding others that should be returned. This happens on consecutive queries sent seconds apart. Do you have any ideas on what happens? Would it be helpful to post the filter?
The filter works fine if not used in the alias context.
The text was updated successfully, but these errors were encountered: