Skip to content

Commit

Permalink
Autocompleting a search query with a suggester field subset (Azure#99)
Browse files Browse the repository at this point in the history
* autocomplte UT with suggester

* remove duplicate tests
  • Loading branch information
navalev authored Sep 24, 2019
1 parent 262b275 commit 80a971b
Show file tree
Hide file tree
Showing 6 changed files with 109 additions and 201 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,32 +104,6 @@ public void canAutocompleteOneTermWithContext() {
validateResults(expectedText, expectedQueryPlusText, results);
}

@Override
public void canAutocompleteOneTermWithFuzzy() {
List<String> expectedText = Arrays.asList("model", "modern", "morel", "motel");
List<String> expectedQueryPlusText = Arrays.asList("model", "modern", "morel", "motel");

AutocompleteParameters params = new AutocompleteParameters();
params.autocompleteMode(AutocompleteMode.ONE_TERM);
params.useFuzzyMatching(true);

PagedFlux<AutocompleteItem> results = client.autocomplete("mod", "sg", null, params);
validateResults(expectedText, expectedQueryPlusText, results);
}

@Override
public void canAutocompleteOneTermWithContextWithFuzzy() {
List<String> expectedText = Arrays.asList("very polite", "very police");
List<String> expectedQueryPlusText = Arrays.asList("very polite", "very police");

AutocompleteParameters params = new AutocompleteParameters();
params.autocompleteMode(AutocompleteMode.ONE_TERM_WITH_CONTEXT);
params.useFuzzyMatching(true);

PagedFlux<AutocompleteItem> results = client.autocomplete("very polit", "sg", null, params);
validateResults(expectedText, expectedQueryPlusText, results);
}

@Override
public void canAutocompleteStaticallyTypedDocuments() {
List<String> expectedText = Arrays.asList("point", "police", "polite", "pool", "popular");
Expand Down Expand Up @@ -168,31 +142,47 @@ public void canAutocompleteTwoTerms() {
}

@Override
public void canAutocompleteTwoTermsWithFuzzy() {
List<String> expectedText = Arrays.asList("model suites", "modern architecture", "modern stay", "morel coverings", "motel");
List<String> expectedQueryPlusText = Arrays.asList("model suites", "modern architecture", "modern stay", "morel coverings", "motel");
public void testAutocompleteCanUseHitHighlighting() throws Exception {
List<String> expectedText = Arrays.asList("pool", "popular");
List<String> expectedQueryPlusText = Arrays.asList("<b>pool</b>", "<b>popular</b>");

AutocompleteParameters params = new AutocompleteParameters();
params.autocompleteMode(AutocompleteMode.TWO_TERMS);
params.useFuzzyMatching(true);
AutocompleteParameters params = new AutocompleteParameters()
.autocompleteMode(AutocompleteMode.ONE_TERM)
.filter("HotelName eq 'EconoStay' or HotelName eq 'Fancy Stay'")
.highlightPreTag("<b>")
.highlightPostTag("</b>");

PagedFlux<AutocompleteItem> results = client.autocomplete("po", "sg", null, params);

Assert.assertNotNull(results);
validateResults(expectedText, expectedQueryPlusText, results);
}

@Override
public void testAutocompleteWithMultipleSelectedFields() throws Exception {
List<String> expectedText = Arrays.asList("model", "modern");
List<String> expectedQueryPlusText = Arrays.asList("model", "modern");
AutocompleteParameters params = new AutocompleteParameters()
.autocompleteMode(AutocompleteMode.ONE_TERM)
.searchFields(Arrays.asList("HotelName", "Description"));

PagedFlux<AutocompleteItem> results = client.autocomplete("mod", "sg", null, params);

Assert.assertNotNull(results);
validateResults(expectedText, expectedQueryPlusText, results);
}

@Override
public void testAutocompleteCanUseHitHighlighting() throws Exception {
List<String> expectedText = Arrays.asList("pool", "popular");
List<String> expectedQueryPlusText = Arrays.asList("<b>pool</b>", "<b>popular</b>");
public void testAutocompleteWithSelectedFields() throws Exception {
List<String> expectedText = Arrays.asList("modern");
List<String> expectedQueryPlusText = Arrays.asList("modern");

AutocompleteParameters params = new AutocompleteParameters()
.autocompleteMode(AutocompleteMode.ONE_TERM)
.filter("HotelName eq 'EconoStay' or HotelName eq 'Fancy Stay'")
.highlightPreTag("<b>")
.highlightPostTag("</b>");
.searchFields(Arrays.asList("HotelName"))
.filter("HotelId eq '7'");

PagedFlux<AutocompleteItem> results = client.autocomplete("po", "sg", null, params);
PagedFlux<AutocompleteItem> results = client.autocomplete("mod", "sg", null, params);

Assert.assertNotNull(results);
validateResults(expectedText, expectedQueryPlusText, results);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,38 +74,6 @@ public void canAutocompleteOneTermWithContext() {
validateResults(results, expectedText, expectedQueryPlusText);
}

@Override
public void canAutocompleteOneTermWithFuzzy() {
List<String> expectedText = Arrays.asList("model", "modern", "morel", "motel");
List<String> expectedQueryPlusText = Arrays.asList("model", "modern", "morel", "motel");

AutocompleteParameters params = new AutocompleteParameters();
params.autocompleteMode(AutocompleteMode.ONE_TERM);
params.useFuzzyMatching(true);

PagedIterable<AutocompleteItem> results = client.autocomplete("mod", "sg", null, params);
results.iterableByPage().iterator().next();

Assert.assertNotNull(results);
validateResults(results, expectedText, expectedQueryPlusText);
}

@Override
public void canAutocompleteOneTermWithContextWithFuzzy() {
List<String> expectedText = Arrays.asList("very polite", "very police");
List<String> expectedQueryPlusText = Arrays.asList("very polite", "very police");

AutocompleteParameters params = new AutocompleteParameters();
params.autocompleteMode(AutocompleteMode.ONE_TERM_WITH_CONTEXT);
params.useFuzzyMatching(true);

PagedIterable<AutocompleteItem> results = client.autocomplete("very polit", "sg", null, params);
results.iterableByPage().iterator().next();

Assert.assertNotNull(results);
validateResults(results, expectedText, expectedQueryPlusText);
}

@Test
public void canAutocompleteExcludesFieldsNotInSuggester() {
AutocompleteParameters params = new AutocompleteParameters();
Expand Down Expand Up @@ -191,13 +159,31 @@ public void canAutocompleteTwoTerms() {
}

@Override
public void canAutocompleteTwoTermsWithFuzzy() {
List<String> expectedText = Arrays.asList("model suites", "modern architecture", "modern stay", "morel coverings", "motel");
List<String> expectedQueryPlusText = Arrays.asList("model suites", "modern architecture", "modern stay", "morel coverings", "motel");
public void testAutocompleteCanUseHitHighlighting() {
List<String> expectedText = Arrays.asList("pool", "popular");
List<String> expectedQueryPlusText = Arrays.asList("<b>pool</b>", "<b>popular</b>");

AutocompleteParameters params = new AutocompleteParameters();
params.autocompleteMode(AutocompleteMode.TWO_TERMS);
params.useFuzzyMatching(true);
AutocompleteParameters params = new AutocompleteParameters()
.autocompleteMode(AutocompleteMode.ONE_TERM)
.filter("HotelName eq 'EconoStay' or HotelName eq 'Fancy Stay'")
.highlightPreTag("<b>")
.highlightPostTag("</b>");

PagedIterable<AutocompleteItem> results = client.autocomplete("po", "sg", null, params);
results.iterableByPage().iterator().next();

Assert.assertNotNull(results);
validateResults(results, expectedText, expectedQueryPlusText);
}

@Override
public void testAutocompleteWithMultipleSelectedFields() throws Exception {
List<String> expectedText = Arrays.asList("model", "modern");
List<String> expectedQueryPlusText = Arrays.asList("model", "modern");

AutocompleteParameters params = new AutocompleteParameters()
.autocompleteMode(AutocompleteMode.ONE_TERM)
.searchFields(Arrays.asList("HotelName", "Description"));

PagedIterable<AutocompleteItem> results = client.autocomplete("mod", "sg", null, params);
results.iterableByPage().iterator().next();
Expand All @@ -207,17 +193,16 @@ public void canAutocompleteTwoTermsWithFuzzy() {
}

@Override
public void testAutocompleteCanUseHitHighlighting() {
List<String> expectedText = Arrays.asList("pool", "popular");
List<String> expectedQueryPlusText = Arrays.asList("<b>pool</b>", "<b>popular</b>");
public void testAutocompleteWithSelectedFields() throws Exception {
List<String> expectedText = Arrays.asList("modern");
List<String> expectedQueryPlusText = Arrays.asList("modern");

AutocompleteParameters params = new AutocompleteParameters()
.autocompleteMode(AutocompleteMode.ONE_TERM)
.filter("HotelName eq 'EconoStay' or HotelName eq 'Fancy Stay'")
.highlightPreTag("<b>")
.highlightPostTag("</b>");
.searchFields(Arrays.asList("HotelName"))
.filter("HotelId eq '7'");

PagedIterable<AutocompleteItem> results = client.autocomplete("po", "sg", null, params);
PagedIterable<AutocompleteItem> results = client.autocomplete("mod", "sg", null, params);
results.iterableByPage().iterator().next();

Assert.assertNotNull(results);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,6 @@ protected void beforeTest() {
@Test
public abstract void canAutocompleteOneTermWithContext() throws Exception;

@Test
public abstract void canAutocompleteOneTermWithFuzzy() throws Exception;

@Test
public abstract void canAutocompleteOneTermWithContextWithFuzzy() throws Exception;

@Test
public abstract void canAutocompleteStaticallyTypedDocuments() throws Exception;

Expand All @@ -50,10 +44,13 @@ protected void beforeTest() {
public abstract void canAutocompleteTwoTerms() throws Exception;

@Test
public abstract void canAutocompleteTwoTermsWithFuzzy() throws Exception;
public abstract void testAutocompleteCanUseHitHighlighting() throws Exception;

@Test
public abstract void testAutocompleteCanUseHitHighlighting() throws Exception;
public abstract void testAutocompleteWithMultipleSelectedFields() throws Exception;

@Test
public abstract void testAutocompleteWithSelectedFields() throws Exception;

@Test
public abstract void testAutocompleteTopTrimsResults() throws Exception;
Expand Down

This file was deleted.

Loading

0 comments on commit 80a971b

Please sign in to comment.