Matthieu Gautier
c4f706863c
Merge pull request #778 from kiwix/small_fixes
2022-06-02 17:20:06 +02:00
Matthieu Gautier
fbc7656b3f
Use proper argument order when building the SearchRenderer from a Searcher
2022-06-02 17:08:50 +02:00
Matthieu Gautier
d196496802
Make the Searcher owning the stored Reader
...
If we keep a reference to a `Reader` it is better to (share) owning
the reference. Else the reader may be deleted after we create the searcher.
This is especially the case now we are creating the `Reader` at demand
and we don't store it in the library's cache.
2022-06-02 17:08:17 +02:00
Matthieu Gautier
3704d8ab87
Merge pull request #729 from kiwix/multizimsearch
2022-06-02 12:49:57 +02:00
Matthieu Gautier
a7651d0e9b
Check early that provided bookIds are valid
2022-06-02 12:37:52 +02:00
Matthieu Gautier
3bca43344f
Correctly url encode querystring
...
Fix tests with querystring needed url encoding
(pattern=jazz&books.query.title=Ray%20Charles)
2022-06-02 12:37:52 +02:00
Matthieu Gautier
b857293cfd
Build the bookSelection query string when we parse the query.
...
We have to reuse the query the user give us to generate the
pagination links.
At search result rendering step we don't have access to the query object.
The best place to know which arguments are used to select books
(and so which arguments to keep in the pagination links) is when we
parse the query to select books.
Fix tests (pagination links) with book selector other than "books.id="
(pattern=jazz&books.query.lang=eng)
2022-06-02 12:37:52 +02:00
Matthieu Gautier
b483a8e4e4
Make the request_context be able to generate a querystring for a subset.
...
The request_context can now take a filter to select arguments to
keep in the query string.
2022-06-02 12:37:52 +02:00
Matthieu Gautier
e2ab7fd62e
Add some more testing.
...
Note that some tests are failing and will be fixed in next commits.
2022-06-02 12:37:52 +02:00
Veloman Yunkan
f45962c697
First test case for multizim search
2022-06-02 12:37:52 +02:00
Veloman Yunkan
3b3d7ad9c4
Preparing to enhance the search results testsuite
...
Providing the core part of the query explicitly in the search results
testsuite test data.
2022-06-02 12:37:52 +02:00
Matthieu Gautier
1514661c26
Protect search from multi threading race condition.
...
libzim's search is not thread safe (mainly because xapian is not).
So we must protect our search objects from multi thread calls.
The best way to do this is to associate a mutex to the `zim::Searcher`
and lock the searcher each time we access object derivated from the
searcher (search, results, iterator, ...)
2022-06-02 12:37:52 +02:00
Matthieu Gautier
e5ea210d2c
Add a template specialization for ConcurrentCache storing shared_ptr
...
When ConcurrentCache store a shared_ptr we may have shared_ptr in used
while the ConcurrentCache has drop it.
When we "recreate" a value to put in the cache, we don't want to recreate
it, but copying the shared_ptr in use.
To do so we use a (unlimited) store of weak_ptr (aka `WeakStore`)
Every created shared_ptr added to the cache has a weak_ptr ref also stored
in the WeakStore, and we check the WeakStore before creating the value.
2022-06-02 12:37:52 +02:00
Matthieu Gautier
2b38d2cf1b
Copy the lrucache test from libzim.
...
- Adapt lrucache.cpp for rigth include path
and use `kiwix::lru_cache` instead of `zim::lru_cache`.
- Add missing `#include <set>` in lrucache.h
2022-06-02 12:37:52 +02:00
Matthieu Gautier
0081b4d8e7
Make the limit of zim files per search configurable.
...
The default value is 0, which means no limit.
2022-06-02 12:37:52 +02:00
Matthieu Gautier
b74910b2af
Limit the number of zim in multizim fulltext search.
...
We are currently limiting to 5 but it will be changed in next commit.
2022-06-02 12:37:50 +02:00
Matthieu Gautier
cf30233358
Prefix env variable name with `KIWIX_`
2022-06-02 12:23:43 +02:00
Matthieu Gautier
f0065fdd6f
Introduce Error exception to do i18n
2022-06-02 12:23:42 +02:00
Matthieu Gautier
c72132054d
Move i18n helper functions
2022-06-02 12:22:28 +02:00
Matthieu Gautier
077ceac5a5
Make the search_rendered handle multizim search.
...
This introduce a intermediate mustache object to store information
about the request made by the user.
2022-06-02 12:22:28 +02:00
Matthieu Gautier
39d0a56be8
Use selectBooks in handle_search
2022-06-02 12:22:28 +02:00
Matthieu Gautier
76d5fafb72
Introduce `selectBooks`
...
`selectBooks` allow us to parse a query in a "standard" way to get
the book(s) on which the user want to work.
2022-06-02 12:22:28 +02:00
Matthieu Gautier
4438106c2f
Add a prefix in get_search_filter
...
The prefix will be used to parse a "query to select book" in different context.
For now we have only one context : selecting books for the catalog search.
But we will want to select books to do fulltext search on them
(will be done in later commit)
2022-06-02 12:22:28 +02:00
Matthieu Gautier
76ebfd7ea4
Move get_search_filter and subrange.
2022-06-02 12:22:27 +02:00
Matthieu Gautier
22996e4a6b
Allow user to select multiple books when doing search.
2022-06-02 12:22:27 +02:00
Matthieu Gautier
98c54b2279
Handle multiple arguments in RequestContext.
2022-06-02 12:22:27 +02:00
Matthieu Gautier
854623618c
Use the newly introduced searcherCache for multizim searcher.
2022-06-02 12:22:25 +02:00
Matthieu Gautier
fd0edbba80
Use a set of id as key for a the searcher Cache.
...
It will allow use to cache seacher for multiple zim files.
2022-05-24 14:55:48 +02:00
Matthieu Gautier
f5af0633ec
Move the searcher cache into the Library
2022-05-24 14:55:48 +02:00
Matthieu Gautier
740581c55c
Link the cache size to the book count.
...
Unless explicitly set via user env variable.
2022-05-24 14:55:48 +02:00
Matthieu Gautier
582e3ec46d
Use a concurrent cache to store Archive cache.
2022-05-24 14:55:48 +02:00
Matthieu Gautier
28fb76bbc2
Remove m_readers in `Library::impl`
...
It is a deprecated interface and it is a simple wrapper on Archive.
2022-05-24 14:55:48 +02:00
Matthieu Gautier
7c688a4acc
Move `getCacheLength` to a generic helper function `getEnvVar`
2022-05-24 14:55:48 +02:00
Kelson
d4da05e591
Merge pull request #764 from kiwix/pre_multisearch
...
Preparatory work on multizim
2022-05-23 19:29:08 +02:00
Matthieu Gautier
66b2449800
Remove unnecessary catch
...
Catch of std::exception is already made in `handle_request`
2022-05-23 19:17:28 +02:00
Matthieu Gautier
aad95e3413
Introduce a results intermediate object in the template rendering.
...
Url in href must not be html encoded. As we already url encode the path, it
is ok to have `'` in the url.
2022-05-23 19:16:14 +02:00
Matthieu Gautier
f0dd34b6db
Introduce buildQueryData helper in SearchRenderer
2022-05-23 19:13:25 +02:00
Matthieu Gautier
bbdde93f49
Introduce a pagination object to render search result.
2022-05-23 19:12:17 +02:00
Matthieu Gautier
cb62da65c3
Raise a exception if something went wrong in the template rendering.
2022-05-23 10:56:39 +02:00
Matthieu Gautier
288b4ae7df
Fix count of remote books in `Library::Impl::getBookCount`
2022-05-23 10:56:39 +02:00
Matthieu Gautier
52c12b0c2f
Introduce `Library::Impl::getBookCount`
...
We simply introduce a `getBookCount` which is not protected by a lock.
2022-05-23 10:56:39 +02:00
Matthieu Gautier
4695f47dd2
Introduce operator+= to simplify response creation.
2022-05-23 10:56:39 +02:00
Matthieu Gautier
f42f6a60df
Use extractFromString to parse request argument.
...
On top of reusing code, it throw a exception if we cannot convert given
argument in the type we want.
2022-05-23 10:56:39 +02:00
Matthieu Gautier
717c39f2ef
Better ExtractFromString
...
- Throw a exception if we cannot extract from string.
(We throw the same exception as `std::sto*`)
- Add a specialization to extract string from string
- Add some unit test
2022-05-23 10:56:39 +02:00
Matthieu Gautier
aa1f73472d
Remove unecessary BookDB helper class.
...
It was needed to not expose Xapian in public header.
Now we can remove it and directly use a Xapian db.
2022-05-23 10:56:39 +02:00
Matthieu Gautier
090c2fd31a
Move LibraryBase out of public API.
...
We use composition instead of inheritance to implement Library.
2022-05-23 10:56:39 +02:00
Matthieu Gautier
ff2c7b1fb2
Merge pull request #765 from kiwix/unittests_for_search_results_page
2022-05-23 10:55:28 +02:00
Veloman Yunkan
963362e1ea
One more test-point for search result pagination
2022-05-18 13:30:42 +04:00
Veloman Yunkan
1a8d874a2c
Testing the request for an out-of-bounds page
2022-05-18 13:30:42 +04:00
Veloman Yunkan
8e7658bb10
Almost full coverage of search result pagination
...
The snippets in the test data had to be updated to account for
pagination-dependent snippet variability of pre-7.2.2 libzim.
2022-05-18 13:28:52 +04:00