-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(search): restore prefix phrase match on quoted search (#11444)
- Loading branch information
1 parent
2ceb8e0
commit b17d776
Showing
7 changed files
with
153 additions
and
35 deletions.
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