mirror of
https://github.com/datahub-project/datahub.git
synced 2025-06-27 05:03:31 +00:00
fix(search) Increase weight on fieldPath field for searching (#7725)
Co-authored-by: Indy Prentice <indy@ip-192-168-5-57.us-west-2.compute.internal>
This commit is contained in:
parent
8457ac75a7
commit
f23693156d
@ -56,7 +56,7 @@ public class ESTestConfiguration {
|
|||||||
|
|
||||||
PartialConfiguration partialConfiguration = new PartialConfiguration();
|
PartialConfiguration partialConfiguration = new PartialConfiguration();
|
||||||
partialConfiguration.setFactor(0.4f);
|
partialConfiguration.setFactor(0.4f);
|
||||||
partialConfiguration.setUrnFactor(0.7f);
|
partialConfiguration.setUrnFactor(0.5f);
|
||||||
|
|
||||||
searchConfiguration.setExactMatch(exactMatchConfiguration);
|
searchConfiguration.setExactMatch(exactMatchConfiguration);
|
||||||
searchConfiguration.setPartial(partialConfiguration);
|
searchConfiguration.setPartial(partialConfiguration);
|
||||||
|
@ -1150,6 +1150,35 @@ public class SampleDataFixtureTests extends AbstractTestNGSpringContextTests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testColumnExactMatch() {
|
||||||
|
String query = "unit_data";
|
||||||
|
SearchResult result = search(searchService, query);
|
||||||
|
assertTrue(result.hasEntities() && !result.getEntities().isEmpty(),
|
||||||
|
String.format("%s - Expected search results", query));
|
||||||
|
assertTrue(result.getEntities().stream().noneMatch(e -> e.getMatchedFields().isEmpty()),
|
||||||
|
String.format("%s - Expected search results to include matched fields", query));
|
||||||
|
|
||||||
|
assertTrue(result.getEntities().size() > 2,
|
||||||
|
String.format("%s - Expected search results to have at least two results", query));
|
||||||
|
assertEquals(result.getEntities().get(0).getEntity().toString(),
|
||||||
|
"urn:li:dataset:(urn:li:dataPlatform:testOnly," + query + ",PROD)",
|
||||||
|
"Expected table name exact match first");
|
||||||
|
|
||||||
|
query = "special_column_only_present_here_info";
|
||||||
|
result = search(searchService, query);
|
||||||
|
assertTrue(result.hasEntities() && !result.getEntities().isEmpty(),
|
||||||
|
String.format("%s - Expected search results", query));
|
||||||
|
assertTrue(result.getEntities().stream().noneMatch(e -> e.getMatchedFields().isEmpty()),
|
||||||
|
String.format("%s - Expected search results to include matched fields", query));
|
||||||
|
|
||||||
|
assertTrue(result.getEntities().size() > 2,
|
||||||
|
String.format("%s - Expected search results to have at least two results", query));
|
||||||
|
assertEquals(result.getEntities().get(0).getEntity().toString(),
|
||||||
|
"urn:li:dataset:(urn:li:dataPlatform:testOnly," + "important_units" + ",PROD)",
|
||||||
|
"Expected table with column name exact match first");
|
||||||
|
}
|
||||||
|
|
||||||
private Stream<AnalyzeResponse.AnalyzeToken> getTokens(AnalyzeRequest request) throws IOException {
|
private Stream<AnalyzeResponse.AnalyzeToken> getTokens(AnalyzeRequest request) throws IOException {
|
||||||
return _searchClient.indices().analyze(request, RequestOptions.DEFAULT).getTokens().stream();
|
return _searchClient.indices().analyze(request, RequestOptions.DEFAULT).getTokens().stream();
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
@ -15,7 +15,8 @@ record SchemaField {
|
|||||||
*/
|
*/
|
||||||
@Searchable = {
|
@Searchable = {
|
||||||
"fieldName": "fieldPaths",
|
"fieldName": "fieldPaths",
|
||||||
"fieldType": "TEXT"
|
"fieldType": "TEXT",
|
||||||
|
"boostScore": 5.0
|
||||||
}
|
}
|
||||||
fieldPath: SchemaFieldPath
|
fieldPath: SchemaFieldPath
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user