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:
Indy Prentice 2023-04-05 17:45:37 -05:00 committed by GitHub
parent 8457ac75a7
commit f23693156d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 32 additions and 2 deletions

View File

@ -56,7 +56,7 @@ public class ESTestConfiguration {
PartialConfiguration partialConfiguration = new PartialConfiguration();
partialConfiguration.setFactor(0.4f);
partialConfiguration.setUrnFactor(0.7f);
partialConfiguration.setUrnFactor(0.5f);
searchConfiguration.setExactMatch(exactMatchConfiguration);
searchConfiguration.setPartial(partialConfiguration);

View File

@ -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 {
return _searchClient.indices().analyze(request, RequestOptions.DEFAULT).getTokens().stream();
}

View File

@ -15,7 +15,8 @@ record SchemaField {
*/
@Searchable = {
"fieldName": "fieldPaths",
"fieldType": "TEXT"
"fieldType": "TEXT",
"boostScore": 5.0
}
fieldPath: SchemaFieldPath