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
Resolve now
in date ranges in percolator and alias filters at search time instead of parse time
#8534
Merged
martijnvg
merged 1 commit into
elastic:1.x
from
martijnvg:bugs/alias_filter_and_percolator_query_with_now_based_range
Nov 19, 2014
Merged
Resolve now
in date ranges in percolator and alias filters at search time instead of parse time
#8534
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
src/main/java/org/elasticsearch/common/lucene/search/NoCacheQuery.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Licensed to Elasticsearch under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.elasticsearch.common.lucene.search; | ||
|
||
import org.apache.lucene.search.Query; | ||
|
||
/** | ||
* Queries are never cached directly, but a query can be wrapped in a filter that may end being cached. | ||
* Filters that wrap this query either directly or indirectly will never be cached. | ||
*/ | ||
public abstract class NoCacheQuery extends Query { | ||
|
||
@Override | ||
public final String toString(String s) { | ||
return "no_cache(" + innerToString(s) + ")"; | ||
} | ||
|
||
public abstract String innerToString(String s); | ||
} |
49 changes: 49 additions & 0 deletions
49
src/main/java/org/elasticsearch/common/lucene/search/ResolvableFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Licensed to Elasticsearch under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.elasticsearch.common.lucene.search; | ||
|
||
import org.apache.lucene.index.AtomicReaderContext; | ||
import org.apache.lucene.search.DocIdSet; | ||
import org.apache.lucene.search.Filter; | ||
import org.apache.lucene.util.Bits; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* A filter implementation that resolves details at the last possible moment between filter parsing and execution. | ||
* For example a date filter based on 'now'. | ||
*/ | ||
public abstract class ResolvableFilter extends Filter { | ||
|
||
/** | ||
* @return The actual filter instance to be executed containing the latest details. | ||
*/ | ||
public abstract Filter resolve(); | ||
|
||
@Override | ||
public DocIdSet getDocIdSet(AtomicReaderContext context, Bits acceptDocs) throws IOException { | ||
Filter resolvedFilter = resolve(); | ||
if (resolvedFilter != null) { | ||
return resolvedFilter.getDocIdSet(context, acceptDocs); | ||
} else { | ||
return null; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we actually need to only wrap this in a
LateParsingFilter
if there is no context? can't we do this all the time and in our tests do the resolve instead? I don't like the special casing based on the context here to be honestThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like to do that too, but this does mean that the resolve method is invoked for each segment that filter is going to execute on. See QueryParseContext#cacheFilter(...) around line 214.
Would this side effect be acceptable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should just stick with what we have for now :/ filter needs a rewrite method