-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
fix(search): restore prefix phrase match on quoted search #11444
Merged
david-leifker
merged 1 commit into
datahub-project:master
from
david-leifker:quoted-search-config
Sep 20, 2024
Merged
Changes from all commits
Commits
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
47 changes: 47 additions & 0 deletions
47
...ta-io/src/test/java/com/linkedin/metadata/search/fixtures/SampleDataFixtureSetupTest.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,47 @@ | ||
package com.linkedin.metadata.search.fixtures; | ||
|
||
import static org.testng.AssertJUnit.assertEquals; | ||
|
||
import com.fasterxml.jackson.dataformat.yaml.YAMLMapper; | ||
import com.linkedin.metadata.config.search.custom.CustomSearchConfiguration; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.util.List; | ||
import java.util.Map; | ||
import org.springframework.core.io.ClassPathResource; | ||
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; | ||
import org.testng.annotations.Test; | ||
|
||
public class SampleDataFixtureSetupTest extends AbstractTestNGSpringContextTests { | ||
private static final String DEFAULT_CONFIG = "search_config.yaml"; | ||
private static final String TEST_FIXTURE_CONFIG = "search_config_fixture_test.yml"; | ||
private static final YAMLMapper MAPPER = new YAMLMapper(); | ||
|
||
/** | ||
* Ensure default search configuration matches the test fixture configuration (allowing for some | ||
* differences) | ||
*/ | ||
@Test | ||
public void testConfig() throws IOException { | ||
final CustomSearchConfiguration defaultConfig; | ||
final CustomSearchConfiguration fixtureConfig; | ||
|
||
try (InputStream stream = new ClassPathResource(DEFAULT_CONFIG).getInputStream()) { | ||
defaultConfig = MAPPER.readValue(stream, CustomSearchConfiguration.class); | ||
} | ||
try (InputStream stream = new ClassPathResource(TEST_FIXTURE_CONFIG).getInputStream()) { | ||
fixtureConfig = MAPPER.readValue(stream, CustomSearchConfiguration.class); | ||
|
||
// test specifics | ||
((List<Map<String, Object>>) | ||
fixtureConfig.getQueryConfigurations().get(1).getFunctionScore().get("functions")) | ||
.remove(1); | ||
|
||
((List<Map<String, Object>>) | ||
fixtureConfig.getQueryConfigurations().get(2).getFunctionScore().get("functions")) | ||
.remove(1); | ||
} | ||
|
||
assertEquals(fixtureConfig, defaultConfig); | ||
} | ||
} |
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
84 changes: 66 additions & 18 deletions
84
metadata-io/src/test/resources/search_config_fixture_test.yml
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 |
---|---|---|
@@ -1,51 +1,99 @@ | ||
# Use for testing with search fixtures | ||
queryConfigurations: | ||
# Select * | ||
# Select */explore all | ||
# Attempt to rank active incidents at the top followed by enrichment factors | ||
- queryRegex: '[*]|' | ||
simpleQuery: false | ||
prefixMatchQuery: false | ||
exactMatchQuery: false | ||
functionScore: | ||
functions: | ||
- filter: | ||
match_all: {} | ||
weight: 1 | ||
term: | ||
hasActiveIncidents: | ||
value: true | ||
weight: 2.0 | ||
- filter: | ||
term: | ||
hasDescription: | ||
value: true | ||
weight: 1.25 | ||
- filter: | ||
term: | ||
hasOwners: | ||
value: true | ||
weight: 1.25 | ||
- filter: | ||
term: | ||
hasDomain: | ||
value: true | ||
weight: 1.1 | ||
- filter: | ||
term: | ||
hasGlossaryTerms: | ||
value: true | ||
weight: 1.1 | ||
- filter: | ||
term: | ||
hasTags: | ||
value: true | ||
weight: 1.1 | ||
- filter: | ||
term: | ||
hasRowCount: | ||
value: true | ||
weight: 1.05 | ||
- filter: | ||
term: | ||
materialized: | ||
hasColumnCount: | ||
value: true | ||
weight: 0.5 | ||
weight: 1.05 | ||
- filter: | ||
term: | ||
deprecated: | ||
value: true | ||
weight: 0.5 | ||
score_mode: avg | ||
boost_mode: multiply | ||
weight: 0.25 | ||
score_mode: multiply | ||
boost_mode: replace | ||
|
||
- queryRegex: .* | ||
simpleQuery: true | ||
# Criteria for exact-match only | ||
# Contains quotes, is a single term with `_`, `.`, or `-` (normally consider for tokenization) then use exact match query | ||
- queryRegex: >- | ||
^["'].+["']$|^[a-zA-Z0-9]\S+[_.-]\S+[a-zA-Z0-9]$ | ||
simpleQuery: false | ||
prefixMatchQuery: true | ||
exactMatchQuery: true | ||
functionScore: | ||
functions: | ||
- filter: | ||
match_all: {} | ||
weight: 1 | ||
- filter: | ||
term: | ||
materialized: | ||
deprecated: | ||
value: true | ||
weight: 0.5 | ||
weight: 0.25 | ||
- filter: | ||
terms: | ||
tags: | ||
- urn:li:tag:pii | ||
weight: 1.25 | ||
score_mode: multiply | ||
boost_mode: multiply | ||
|
||
# default | ||
- queryRegex: .* | ||
simpleQuery: true | ||
prefixMatchQuery: true | ||
exactMatchQuery: true | ||
functionScore: | ||
functions: | ||
- filter: | ||
term: | ||
deprecated: | ||
value: true | ||
weight: 0.5 | ||
weight: 0.25 | ||
- filter: | ||
terms: | ||
tags: | ||
- urn:li:tag:pii | ||
weight: 1.25 | ||
score_mode: avg | ||
boost_mode: multiply | ||
score_mode: multiply | ||
boost_mode: multiply |
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.
This is the impactful change here