forked from opensearch-project/OpenSearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Harsha Vamsi Kalluri <[email protected]>
- Loading branch information
1 parent
ff8a2fd
commit b1d5dd6
Showing
7 changed files
with
121 additions
and
118 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
69 changes: 69 additions & 0 deletions
69
server/src/main/java/org/opensearch/search/approximate/ApproximateIndexOrDocValuesQuery.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,69 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.search.approximate; | ||
|
||
import org.apache.lucene.search.IndexOrDocValuesQuery; | ||
import org.apache.lucene.search.IndexSearcher; | ||
import org.apache.lucene.search.Query; | ||
import org.apache.lucene.search.QueryVisitor; | ||
import org.apache.lucene.search.ScoreMode; | ||
import org.apache.lucene.search.Weight; | ||
|
||
import java.io.IOException; | ||
|
||
public final class ApproximateIndexOrDocValuesQuery extends ApproximateScoreQuery { | ||
|
||
private final ApproximateableQuery approximateIndexQuery; | ||
private final IndexOrDocValuesQuery indexOrDocValuesQuery; | ||
|
||
public ApproximateIndexOrDocValuesQuery(Query indexQuery, ApproximateableQuery approximateIndexQuery, Query dvQuery) { | ||
super(new IndexOrDocValuesQuery(indexQuery, dvQuery), approximateIndexQuery); | ||
this.approximateIndexQuery = approximateIndexQuery; | ||
this.indexOrDocValuesQuery = new IndexOrDocValuesQuery(indexQuery, dvQuery); | ||
} | ||
|
||
@Override | ||
public String toString(String field) { | ||
return "ApproximateIndexOrDocValuesQuery(indexQuery=" | ||
+ indexOrDocValuesQuery.getIndexQuery().toString(field) | ||
+ ", approximateIndexQuery=" | ||
+ approximateIndexQuery.toString(field) | ||
+ ", dvQuery=" | ||
+ indexOrDocValuesQuery.getRandomAccessQuery().toString(field) | ||
+ ")"; | ||
} | ||
|
||
@Override | ||
public void visit(QueryVisitor visitor) { | ||
indexOrDocValuesQuery.visit(visitor); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (sameClassAs(obj) == false) { | ||
return false; | ||
} | ||
ApproximateIndexOrDocValuesQuery that = (ApproximateIndexOrDocValuesQuery) obj; | ||
return indexOrDocValuesQuery.getIndexQuery().equals(that.indexOrDocValuesQuery.getIndexQuery()) | ||
&& indexOrDocValuesQuery.getRandomAccessQuery().equals(that.indexOrDocValuesQuery.getRandomAccessQuery()); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return indexOrDocValuesQuery.hashCode(); | ||
} | ||
|
||
@Override | ||
public Weight createWeight(IndexSearcher searcher, ScoreMode scoreMode, float boost) throws IOException { | ||
if (approximateIndexQuery.canApproximate(this.getContext())) { | ||
return approximateIndexQuery.createWeight(searcher, scoreMode, boost); | ||
} | ||
return indexOrDocValuesQuery.createWeight(searcher, scoreMode, boost); | ||
} | ||
} |
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
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