Refactors the indexing and the syntax
Human queries are now in french. Sorry for that
This commit is contained in:
@@ -44,18 +44,50 @@ func (s *BleveIndexerSuite) TestCanDeleteAlbum(c *C) {
|
||||
|
||||
func (s *BleveIndexerSuite) TestCanSearch(c *C) {
|
||||
data := map[string]map[AlbumID]bool{
|
||||
"frégate": map[AlbumID]bool{albumsDataTest[10].ID: true},
|
||||
"Éditeur:Dupuis": map[AlbumID]bool{8179: true, 9935: true, 160366: true},
|
||||
// Research by amny keyword (here in the description
|
||||
"frégate": map[AlbumID]bool{84448: true},
|
||||
// Research by editor
|
||||
"éditeur:Dupuis": map[AlbumID]bool{8179: true, 9935: true, 160366: true},
|
||||
// Research by Title
|
||||
"titre:\"Mortes saisons\"": map[AlbumID]bool{8179: true},
|
||||
// Keyword can appear in both Title and Description
|
||||
"pour mourir": map[AlbumID]bool{44989: true, 84448: true, 160366: true, 19762: true},
|
||||
// Or in the collection
|
||||
"écho savanes": map[AlbumID]bool{15875: true},
|
||||
// May not find anything, but never fails
|
||||
"FOOOOOOOBAAAAAR": map[AlbumID]bool{},
|
||||
// Or we can only look for collection field
|
||||
"collection:Dupuis": map[AlbumID]bool{160366: true},
|
||||
// Maybe we are only inderested in scenarist
|
||||
"scenario:plantu": map[AlbumID]bool{58595: true},
|
||||
// Or designer
|
||||
"dessins:berthet": map[AlbumID]bool{8179: true},
|
||||
// or colorist, but Trondheim does not does color ;)
|
||||
"couleurs:trondheim": map[AlbumID]bool{},
|
||||
// or any of that fields, yes Trondheim do draw some comics ;)
|
||||
"trondheim": map[AlbumID]bool{160366: true},
|
||||
// or we just want to look up a reference
|
||||
"CHI-23": map[AlbumID]bool{46005: true},
|
||||
// or more explicitely
|
||||
"ref:BERT-9": map[AlbumID]bool{8179: true},
|
||||
// or we are just interested in good comics
|
||||
"Note:>4": map[AlbumID]bool{52100: true, 19762: true, 160366: true},
|
||||
// or bad ones
|
||||
"Note:<2": map[AlbumID]bool{754: true, 32043: true},
|
||||
}
|
||||
start := time.Now()
|
||||
for q, expected := range data {
|
||||
res, err := s.i.Search(q)
|
||||
if c.Check(err, IsNil) == true {
|
||||
if c.Check(len(res), Equals, len(expected)) == true {
|
||||
if c.Check(len(res), Equals, len(expected), Commentf("Query: %s", q)) == true {
|
||||
for _, resAlbum := range res {
|
||||
_, ok := expected[resAlbum.ID]
|
||||
c.Check(ok, Equals, true, Commentf("Looking for %d in %s", resAlbum.ID, expected))
|
||||
c.Check(ok, Equals, true, Commentf("Query: %s, got %d instead of %v", q, resAlbum.ID, expected))
|
||||
}
|
||||
} else {
|
||||
log.Printf("Got %d result(s)", len(res))
|
||||
for i, a := range res {
|
||||
log.Printf(" - %d: %d: %s", i, a.ID, a.Title)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user