-
Notifications
You must be signed in to change notification settings - Fork 25
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
rest api: add simple query support #973
Conversation
90482b5
to
d1ce1bf
Compare
Tests of simple search on ilsdev: 1. Search on a series (ex: Que sais-je ?) Que sais-je => returns 174 records There is an encoding of the question mark (?) to ?. You can see it 2. search on title with brackets works well. Great ! Ex: 500 [cinq cents] modèles au point de croix 3. Facets seems to (still) use OR Do a search on "economie" 4. Search of a term with diacritics should be consistent with the same term without diacritics économie => 431 records I guess it should return the same number of records. |
Other problems to solve or tests to write:
|
1c06803
to
beb3625
Compare
All problems has been fixed and tests has been written. Some of them cannot be addressed such as économie == economie due to the multi lingual support. |
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.
Commit message:
- line 3, change "as describe" to "as described*
- line 5, "as follows" to "as follows:"
- line 10, "Without this parameter, nothing changed" to "Except this parameter, nothing has been modified"
- line 16, "RES" to "REST"
- line 17, "simple query string" to "simple query"?
This commit may close this very old issue: #91
e7cc19e
to
f7f88bd
Compare
24a13c3
to
c855df1
Compare
"fields": { | ||
"analyzed": { | ||
"type": "text", | ||
"analyzer": "custom_keyword" | ||
} |
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.
Really cool feature!
@@ -135,14 +153,25 @@ def search_factory(self, search, query_parser=None): | |||
""" | |||
def _default_parser(qstr=None, query_boosting=[]): | |||
"""Default parser that uses the Q() from elasticsearch_dsl.""" | |||
query_type = 'query_string' | |||
default_operator = 'OR' | |||
if request.args.get('simple'): |
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.
Why operator is set from simple argument. I think it"s not fully related and should be passed as another parameter.
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.
I do not want to have two parameters even if you are again right, it is cleaner.
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.
- Autosuggest display is not optimal when using boolean operators:
- Œ,œ
- Œil or œil, 114 documents
- oeil, 71 documents
- same for ae
- ss, ü, ö are working fine
- The minus to negate a token from the search does not work: example
- Detail: it could be convenient to be able to search by patron birth year (tokenizer for birth date). Currently, full input "1961-11-24" is necessary. Ideally, input "1961" is working as well
6f36fa7
to
d6b77ba
Compare
All has been addressed. |
The current elasticsearch query string used by the REST API is powerful but should not be used for search boxes. It raises exceptions when the query syntax contains errors. As described in the elaticsearch documentation, a simple query string should be used. A new http query optional parameters has been added and can be specified as follows: `&simple=1`. For example: `https://ils.rero.ch/global/search/?q=potter&simple=1`. When the simple query syntax is chosen, the default boolean operator is `AND`. Except this parameter, nothing has been modified. * Adds new type of aggregation filter to perform a AND boolean operator between the terms in the same aggregation. All aggregations filters use now AND boolean operator. * Updates elasticsearch mappings to enhance the search engine quality. * Adds a new REST API list records operator to use a `simple_query_string` instead of a `query_string`. The simple query string preform an AND boolean operator by default. * Adds search query tests. * Adds missing utils test. * Renames `global_lowercase_asciifolding` elasticsearch analyzer to `default`. This makes the rero-ils custom analyzer to be the default for all elasticsearch `text` fields. All elasticsearch mappings has been simplified. * Creates a new `custom_keyword` analyzer. * Creates a custom elasticsearch image with the icu analysis plugin (https://www.elastic.co/guide/en/elasticsearch/plugins/current/analysis-icu.html). * Closes rero#755. * Closes rero#91. * Closes rero#934. * Revisits elasticsearch mappings. * Fixes several JSONSchemas. Co-Authored-by: Johnny Mariéthoz <[email protected]>
The current elasticsearch query string used by the REST API is powerful
but should not be used for search boxes. It raises exceptions when
the query syntax contains errors. As described in the elaticsearch
documentation, a simple query string should be used. A new http query
optional parameters has been added and can be specified as follows:
&simple=1
.For example:
https://ils.rero.ch/global/search/?q=potter&simple=1
.When the simple query syntax is chosen, the default boolean operator is
AND
. Except this parameter, nothing has been modified.between the terms in the same aggregation. All aggregations filters
use now AND boolean operator.
simple_query_string
instead of a
query_string
. The simple query string preform an ANDboolean operator by default.
global_lowercase_asciifolding
elasticsearch analyzer todefault
. This makes the rero-ils custom analyzer to be the default forall elasticsearch
text
fields. All elasticsearch mappings has beensimplified.
custom_keyword
analyzer.(https://www.elastic.co/guide/en/elasticsearch/plugins/current/analysis-icu.html).
Required by
Why are you opening this PR?
How to test?
&simple=1
option parameter. The number of results should be less than without the param. Try also query that causes syntax errors.Note: see (https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-simple-query-string-query.html#simple-query-string-syntax) for the supported syntax documentation.
Code review check list