-
Notifications
You must be signed in to change notification settings - Fork 25k
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
Support search_type
in Rank Evaluation API
#48542
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
78 changes: 78 additions & 0 deletions
78
...ank-eval/src/test/java/org/elasticsearch/index/rankeval/TransportRankEvalActionTests.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,78 @@ | ||
/* | ||
* 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.index.rankeval; | ||
|
||
import org.elasticsearch.action.ActionListener; | ||
import org.elasticsearch.action.search.MultiSearchRequest; | ||
import org.elasticsearch.action.search.MultiSearchResponse; | ||
import org.elasticsearch.action.search.SearchType; | ||
import org.elasticsearch.action.support.ActionFilters; | ||
import org.elasticsearch.action.support.IndicesOptions; | ||
import org.elasticsearch.client.node.NodeClient; | ||
import org.elasticsearch.common.settings.Settings; | ||
import org.elasticsearch.common.xcontent.NamedXContentRegistry; | ||
import org.elasticsearch.env.Environment; | ||
import org.elasticsearch.script.ScriptService; | ||
import org.elasticsearch.search.builder.SearchSourceBuilder; | ||
import org.elasticsearch.test.ESTestCase; | ||
import org.elasticsearch.transport.TransportService; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
import static org.mockito.Mockito.mock; | ||
|
||
public class TransportRankEvalActionTests extends ESTestCase { | ||
|
||
private Settings settings = Settings.builder().put("path.home", createTempDir().toString()).put("node.name", "test-" + getTestName()) | ||
.put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString()).build(); | ||
|
||
/** | ||
* Test that request parameters like indicesOptions or searchType from ranking evaluation request are transfered to msearch request | ||
*/ | ||
public void testTransferRequestParameters() throws Exception { | ||
String indexName = "test_index"; | ||
List<RatedRequest> specifications = new ArrayList<>(); | ||
specifications | ||
.add(new RatedRequest("amsterdam_query", Arrays.asList(new RatedDocument(indexName, "1", 3)), new SearchSourceBuilder())); | ||
RankEvalRequest rankEvalRequest = new RankEvalRequest(new RankEvalSpec(specifications, new DiscountedCumulativeGain()), | ||
new String[] { indexName }); | ||
SearchType expectedSearchType = randomFrom(SearchType.CURRENTLY_SUPPORTED); | ||
rankEvalRequest.searchType(expectedSearchType); | ||
IndicesOptions expectedIndicesOptions = IndicesOptions.fromOptions(randomBoolean(), randomBoolean(), randomBoolean(), | ||
randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean()); | ||
rankEvalRequest.indicesOptions(expectedIndicesOptions); | ||
|
||
NodeClient client = new NodeClient(settings, null) { | ||
@Override | ||
public void multiSearch(MultiSearchRequest request, ActionListener<MultiSearchResponse> listener) { | ||
assertEquals(1, request.requests().size()); | ||
assertEquals(expectedSearchType, request.requests().get(0).searchType()); | ||
assertArrayEquals(new String[]{indexName}, request.requests().get(0).indices()); | ||
assertEquals(expectedIndicesOptions, request.requests().get(0).indicesOptions()); | ||
} | ||
}; | ||
|
||
TransportRankEvalAction action = new TransportRankEvalAction(mock(ActionFilters.class), client, mock(TransportService.class), | ||
mock(ScriptService.class), NamedXContentRegistry.EMPTY); | ||
action.doExecute(null, rankEvalRequest, 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,6 +43,7 @@ setup: | |
- do: | ||
rank_eval: | ||
index: foo, | ||
search_type: query_then_fetch | ||
body: { | ||
"requests" : [ | ||
{ | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,12 +39,9 @@ | |
import org.elasticsearch.tasks.Task; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change doesn't seem to be for this pr ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I pulled this out to #48523 and didn't delete it here. |
||
import org.elasticsearch.tasks.TaskManager; | ||
import org.elasticsearch.test.ESTestCase; | ||
import org.elasticsearch.threadpool.TestThreadPool; | ||
import org.elasticsearch.threadpool.ThreadPool; | ||
import org.elasticsearch.transport.Transport; | ||
import org.elasticsearch.transport.TransportService; | ||
import org.junit.After; | ||
import org.junit.Before; | ||
|
||
import java.util.Arrays; | ||
import java.util.Collections; | ||
|
@@ -63,22 +60,6 @@ | |
|
||
public class TransportMultiSearchActionTests extends ESTestCase { | ||
|
||
protected ThreadPool threadPool; | ||
|
||
@Before | ||
@Override | ||
public void setUp() throws Exception { | ||
super.setUp(); | ||
threadPool = new TestThreadPool(getTestName()); | ||
} | ||
|
||
@After | ||
@Override | ||
public void tearDown() throws Exception { | ||
threadPool.shutdown(); | ||
super.tearDown(); | ||
} | ||
|
||
public void testParentTaskId() throws Exception { | ||
// Initialize dependencies of TransportMultiSearchAction | ||
Settings settings = Settings.builder() | ||
|
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.
Is this really needed ? It should be enough to use the
SearchType
enum ? If not, then the comment should be changed since the types are restricted todfs_query_then_fetch
andquery_then_fetch
.