cadd2a5cbb
Make the HTTPErrorHtmlResponse not Html only.
2022-06-03 15:46:41 +02:00
e51a5b9ebc
Introduce get_requested_format
helper
2022-06-03 15:46:41 +02:00
5d6b0ea96a
Add searchdescription.xml endpoint
2022-06-03 15:46:41 +02:00
e5df5e936f
Render the search result using (opensearch/atom) xml format.
2022-06-03 15:46:41 +02:00
c4f706863c
Merge pull request #778 from kiwix/small_fixes
2022-06-02 17:20:06 +02:00
fbc7656b3f
Use proper argument order when building the SearchRenderer from a Searcher
2022-06-02 17:08:50 +02:00
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
3704d8ab87
Merge pull request #729 from kiwix/multizimsearch
2022-06-02 12:49:57 +02:00
a7651d0e9b
Check early that provided bookIds are valid
2022-06-02 12:37:52 +02:00
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
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
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
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
f45962c697
First test case for multizim search
2022-06-02 12:37:52 +02:00
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
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
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
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
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
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
cf30233358
Prefix env variable name with KIWIX_
2022-06-02 12:23:43 +02:00
f0065fdd6f
Introduce Error exception to do i18n
2022-06-02 12:23:42 +02:00
c72132054d
Move i18n helper functions
2022-06-02 12:22:28 +02:00
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
39d0a56be8
Use selectBooks in handle_search
2022-06-02 12:22:28 +02:00
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
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
76ebfd7ea4
Move get_search_filter and subrange.
2022-06-02 12:22:27 +02:00
22996e4a6b
Allow user to select multiple books when doing search.
2022-06-02 12:22:27 +02:00
98c54b2279
Handle multiple arguments in RequestContext.
2022-06-02 12:22:27 +02:00
854623618c
Use the newly introduced searcherCache for multizim searcher.
2022-06-02 12:22:25 +02:00
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
f5af0633ec
Move the searcher cache into the Library
2022-05-24 14:55:48 +02:00
740581c55c
Link the cache size to the book count.
...
Unless explicitly set via user env variable.
2022-05-24 14:55:48 +02:00
582e3ec46d
Use a concurrent cache to store Archive cache.
2022-05-24 14:55:48 +02:00
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
7c688a4acc
Move getCacheLength
to a generic helper function getEnvVar
2022-05-24 14:55:48 +02:00
d4da05e591
Merge pull request #764 from kiwix/pre_multisearch
...
Preparatory work on multizim
2022-05-23 19:29:08 +02:00
66b2449800
Remove unnecessary catch
...
Catch of std::exception is already made in `handle_request`
2022-05-23 19:17:28 +02:00
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
f0dd34b6db
Introduce buildQueryData helper in SearchRenderer
2022-05-23 19:13:25 +02:00
bbdde93f49
Introduce a pagination object to render search result.
2022-05-23 19:12:17 +02:00
cb62da65c3
Raise a exception if something went wrong in the template rendering.
2022-05-23 10:56:39 +02:00
288b4ae7df
Fix count of remote books in Library::Impl::getBookCount
2022-05-23 10:56:39 +02:00
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
4695f47dd2
Introduce operator+= to simplify response creation.
2022-05-23 10:56:39 +02:00
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
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
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
090c2fd31a
Move LibraryBase out of public API.
...
We use composition instead of inheritance to implement Library.
2022-05-23 10:56:39 +02:00