-
Notifications
You must be signed in to change notification settings - Fork 26
Search changes #317
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
Search changes #317
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -372,7 +372,7 @@ class SearchTests: XCTestCase { | |||||
| XCTAssertEqual(documents.limit, limit) | ||||||
| XCTAssertEqual(documents.hits.count, 1) | ||||||
| let book: Book = documents.hits[0] | ||||||
| XCTAssertEqual("…Joaquim Manuel de Macedo", book.formatted!.comment!) | ||||||
| XCTAssertEqual("…from Joaquim Manuel de Macedo", book.formatted!.comment!) | ||||||
| expectation.fulfill() | ||||||
| case .failure(let error): | ||||||
| dump(error) | ||||||
|
|
@@ -451,7 +451,7 @@ class SearchTests: XCTestCase { | |||||
| typealias MeiliResult = Result<SearchResult<Book>, Swift.Error> | ||||||
| let limit = 5 | ||||||
| let query = "Moreninha" | ||||||
| let parameters = SearchParameters(query: query, limit: limit, matches: true) | ||||||
| let parameters = SearchParameters(query: query, limit: limit, showMatchesPosition: true) | ||||||
|
|
||||||
| self.index.search(parameters) { (result: MeiliResult) in | ||||||
| switch result { | ||||||
|
|
@@ -585,7 +585,7 @@ class SearchTests: XCTestCase { | |||||
| distinctAttribute: nil, | ||||||
| filterableAttributes: filterableAttributes, | ||||||
| sortableAttributes: ["id"] | ||||||
| ) | ||||||
| ) | ||||||
|
|
||||||
| self.index.updateSettings(settings) { result in | ||||||
| switch result { | ||||||
|
|
@@ -720,7 +720,7 @@ class SearchTests: XCTestCase { | |||||
| typealias MeiliResult = Result<SearchResult<Book>, Swift.Error> | ||||||
| let limit = 5 | ||||||
| let query = "A" | ||||||
| let filter = "genres = Novel" | ||||||
| let filter = "genres = Fantasy" | ||||||
| let parameters = SearchParameters(query: query, limit: limit, filter: filter) | ||||||
|
|
||||||
| self.index.search(parameters) { (result: MeiliResult) in | ||||||
|
|
@@ -729,10 +729,9 @@ class SearchTests: XCTestCase { | |||||
| XCTAssertEqual(documents.query, query) | ||||||
| XCTAssertEqual(documents.limit, limit) | ||||||
| XCTAssertEqual(documents.hits.count, 2) | ||||||
| let moreninhaBook: Book = documents.hits.first { book in book.id == 1844 }! | ||||||
| XCTAssertEqual("A Moreninha", moreninhaBook.title) | ||||||
| let petitBook: Book = documents.hits.first { book in book.id == 456 }! | ||||||
| XCTAssertEqual("Le Petit Prince", petitBook.title) | ||||||
|
|
||||||
| XCTAssertEqual(documents.hits.compactMap { $0.title }, ["Alice In Wonderland", "Harry Potter and the Half-Blood Prince"]) | ||||||
|
|
||||||
| expectation.fulfill() | ||||||
| case .failure(let error): | ||||||
| dump(error) | ||||||
|
|
@@ -791,9 +790,9 @@ class SearchTests: XCTestCase { | |||||
| wait(for: [expectation], timeout: TESTS_TIME_OUT) | ||||||
| } | ||||||
|
|
||||||
| // MARK: Facets distribution | ||||||
| // MARK: Facet distribution | ||||||
|
|
||||||
| func testSearchFacetsDistribution() { | ||||||
| func testSearchFacetDistribution() { | ||||||
| let expectation = XCTestExpectation(description: "Search for Books using facets distribution") | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| configureFilters { result in | ||||||
|
|
@@ -802,8 +801,8 @@ class SearchTests: XCTestCase { | |||||
| typealias MeiliResult = Result<SearchResult<Book>, Swift.Error> | ||||||
| let limit = 5 | ||||||
| let query = "A" | ||||||
| let facetsDistribution = ["genres"] | ||||||
| let parameters = SearchParameters(query: query, limit: limit, facetsDistribution: facetsDistribution) | ||||||
| let facets = ["genres"] | ||||||
| let parameters = SearchParameters(query: query, limit: limit, facets: facets) | ||||||
|
|
||||||
| self.index.search(parameters) { (result: MeiliResult) in | ||||||
| switch result { | ||||||
|
|
@@ -812,21 +811,22 @@ class SearchTests: XCTestCase { | |||||
| XCTAssertEqual(documents.limit, limit) | ||||||
| XCTAssertEqual(documents.hits.count, limit) | ||||||
|
|
||||||
| let facetsDistribution = documents.facetsDistribution! | ||||||
| let facetDistribution = documents.facetDistribution! | ||||||
| let expected: [String: [String: Int]] = [ | ||||||
| "genres": [ | ||||||
| "Bildungsroman": 1, | ||||||
| "Classic Regency nove": 1, | ||||||
| "High fantasy": 1, | ||||||
| "Fantasy": 2, | ||||||
| "Novel": 2, | ||||||
| "Bildungsroman": 1 | ||||||
| "High fantasy": 1 | ||||||
| ] | ||||||
| ] | ||||||
| XCTAssertEqual(expected, facetsDistribution) | ||||||
|
|
||||||
| XCTAssertEqual(facetDistribution["genres"]?.keys.sorted(), expected["genres"]?.keys.sorted()) | ||||||
| XCTAssertEqual(facetDistribution["genres"]?.values.sorted(), expected["genres"]?.values.sorted()) | ||||||
| expectation.fulfill() | ||||||
| case .failure(let error): | ||||||
| dump(error) | ||||||
| XCTFail("Failed to search with testSearchFacetsDistribution") | ||||||
| XCTFail("Failed to search with testSearchFacetDistribution") | ||||||
| expectation.fulfill() | ||||||
| } | ||||||
| } | ||||||
|
|
@@ -840,7 +840,7 @@ class SearchTests: XCTestCase { | |||||
| self.wait(for: [expectation], timeout: 2.0) | ||||||
| } | ||||||
|
|
||||||
| func testSearchFacetsDistributionNullValue() { | ||||||
| func testSearchFacetDistributionNullValue() { | ||||||
| let expectation = XCTestExpectation(description: "Search for Books using facets distribution with 0 value") | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the description still relevant? |
||||||
|
|
||||||
| configureFilters { result in | ||||||
|
|
@@ -849,23 +849,23 @@ class SearchTests: XCTestCase { | |||||
| typealias MeiliResult = Result<SearchResult<Book>, Swift.Error> | ||||||
| let limit = 5 | ||||||
| let query = "Petit Prince" | ||||||
| let facetsDistribution = ["genres"] | ||||||
| let facets = ["genres"] | ||||||
| let filter = "genres = comedy" | ||||||
| let parameters = SearchParameters(query: query, limit: limit, filter: filter, facetsDistribution: facetsDistribution) | ||||||
| let parameters = SearchParameters(query: query, limit: limit, filter: filter, facets: facets) | ||||||
|
|
||||||
| self.index.search(parameters) { (result: MeiliResult) in | ||||||
| switch result { | ||||||
| case .success(let documents): | ||||||
| XCTAssertEqual(documents.query, query) | ||||||
| XCTAssertEqual(documents.limit, limit) | ||||||
| XCTAssertEqual(documents.hits.count, 0) | ||||||
| let facetsDistribution = documents.facetsDistribution! | ||||||
| XCTAssertEqual(["genres": [:]], facetsDistribution) | ||||||
| let facetDistribution = documents.facetDistribution! | ||||||
| XCTAssertEqual(["genres": [:]], facetDistribution) | ||||||
|
|
||||||
| expectation.fulfill() | ||||||
| case .failure(let error): | ||||||
| dump(error) | ||||||
| XCTFail("Failed to search with testSearchFacetsDistribution") | ||||||
| XCTFail("Failed to search with testSearchFacetDistribution") | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| expectation.fulfill() | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
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.
The description above
should become using showMatchesPosition. Sorry I can't make a suggestion on it :(