author | Aurelien Campeas <aurelien.campeas@logilab.fr> |
Tue, 28 Jan 2014 15:27:59 +0100 | |
branch | stable |
changeset 9981 | 7099bbd685aa |
parent 8505 | dcd9bc1d1bca |
permissions | -rw-r--r-- |
8505
dcd9bc1d1bca
[ui] provide an autocomplete RQL bar (closes #2439846)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff
changeset
|
1 |
.. _searchbar: |
dcd9bc1d1bca
[ui] provide an autocomplete RQL bar (closes #2439846)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff
changeset
|
2 |
|
dcd9bc1d1bca
[ui] provide an autocomplete RQL bar (closes #2439846)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff
changeset
|
3 |
RQL search bar |
dcd9bc1d1bca
[ui] provide an autocomplete RQL bar (closes #2439846)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff
changeset
|
4 |
-------------- |
dcd9bc1d1bca
[ui] provide an autocomplete RQL bar (closes #2439846)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff
changeset
|
5 |
|
dcd9bc1d1bca
[ui] provide an autocomplete RQL bar (closes #2439846)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff
changeset
|
6 |
The RQL search bar is a visual component, hidden by default, the tiny *search* |
dcd9bc1d1bca
[ui] provide an autocomplete RQL bar (closes #2439846)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff
changeset
|
7 |
input being enough for common use cases. |
dcd9bc1d1bca
[ui] provide an autocomplete RQL bar (closes #2439846)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff
changeset
|
8 |
|
dcd9bc1d1bca
[ui] provide an autocomplete RQL bar (closes #2439846)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff
changeset
|
9 |
An autocompletion helper is provided to help you type valid queries, both |
dcd9bc1d1bca
[ui] provide an autocomplete RQL bar (closes #2439846)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff
changeset
|
10 |
in terms of syntax and in terms of schema validity. |
dcd9bc1d1bca
[ui] provide an autocomplete RQL bar (closes #2439846)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff
changeset
|
11 |
|
dcd9bc1d1bca
[ui] provide an autocomplete RQL bar (closes #2439846)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff
changeset
|
12 |
.. autoclass:: cubicweb.web.views.magicsearch.RQLSuggestionsBuilder |
dcd9bc1d1bca
[ui] provide an autocomplete RQL bar (closes #2439846)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff
changeset
|
13 |
|
dcd9bc1d1bca
[ui] provide an autocomplete RQL bar (closes #2439846)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff
changeset
|
14 |
|
dcd9bc1d1bca
[ui] provide an autocomplete RQL bar (closes #2439846)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff
changeset
|
15 |
How search is performed |
dcd9bc1d1bca
[ui] provide an autocomplete RQL bar (closes #2439846)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff
changeset
|
16 |
+++++++++++++++++++++++ |
dcd9bc1d1bca
[ui] provide an autocomplete RQL bar (closes #2439846)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff
changeset
|
17 |
|
dcd9bc1d1bca
[ui] provide an autocomplete RQL bar (closes #2439846)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff
changeset
|
18 |
You can use the *rql search bar* to either type RQL queries, plain text queries |
dcd9bc1d1bca
[ui] provide an autocomplete RQL bar (closes #2439846)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff
changeset
|
19 |
or standard shortcuts such as *<EntityType>* or *<EntityType> <attrname> <value>*. |
dcd9bc1d1bca
[ui] provide an autocomplete RQL bar (closes #2439846)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff
changeset
|
20 |
|
dcd9bc1d1bca
[ui] provide an autocomplete RQL bar (closes #2439846)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff
changeset
|
21 |
Ultimately, all queries are translated to rql since it's the only |
dcd9bc1d1bca
[ui] provide an autocomplete RQL bar (closes #2439846)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff
changeset
|
22 |
language understood on the server (data) side. To transform the user |
dcd9bc1d1bca
[ui] provide an autocomplete RQL bar (closes #2439846)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff
changeset
|
23 |
query into RQL, CubicWeb uses the so-called *magicsearch component*, |
dcd9bc1d1bca
[ui] provide an autocomplete RQL bar (closes #2439846)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff
changeset
|
24 |
defined in :mod:`cubicweb.web.views.magicsearch`, which in turn |
dcd9bc1d1bca
[ui] provide an autocomplete RQL bar (closes #2439846)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff
changeset
|
25 |
delegates to a number of query preprocessor that are responsible of |
dcd9bc1d1bca
[ui] provide an autocomplete RQL bar (closes #2439846)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff
changeset
|
26 |
interpreting the user query and generating corresponding RQL. |
dcd9bc1d1bca
[ui] provide an autocomplete RQL bar (closes #2439846)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff
changeset
|
27 |
|
dcd9bc1d1bca
[ui] provide an autocomplete RQL bar (closes #2439846)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff
changeset
|
28 |
The code of the main processor loop is easy to understand: |
dcd9bc1d1bca
[ui] provide an autocomplete RQL bar (closes #2439846)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff
changeset
|
29 |
|
dcd9bc1d1bca
[ui] provide an autocomplete RQL bar (closes #2439846)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff
changeset
|
30 |
.. sourcecode:: python |
dcd9bc1d1bca
[ui] provide an autocomplete RQL bar (closes #2439846)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff
changeset
|
31 |
|
dcd9bc1d1bca
[ui] provide an autocomplete RQL bar (closes #2439846)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff
changeset
|
32 |
for proc in self.processors: |
dcd9bc1d1bca
[ui] provide an autocomplete RQL bar (closes #2439846)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff
changeset
|
33 |
try: |
dcd9bc1d1bca
[ui] provide an autocomplete RQL bar (closes #2439846)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff
changeset
|
34 |
return proc.process_query(uquery, req) |
dcd9bc1d1bca
[ui] provide an autocomplete RQL bar (closes #2439846)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff
changeset
|
35 |
except (RQLSyntaxError, BadRQLQuery): |
dcd9bc1d1bca
[ui] provide an autocomplete RQL bar (closes #2439846)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff
changeset
|
36 |
pass |
dcd9bc1d1bca
[ui] provide an autocomplete RQL bar (closes #2439846)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff
changeset
|
37 |
|
dcd9bc1d1bca
[ui] provide an autocomplete RQL bar (closes #2439846)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff
changeset
|
38 |
The idea is simple: for each query processor, try to translate the |
dcd9bc1d1bca
[ui] provide an autocomplete RQL bar (closes #2439846)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff
changeset
|
39 |
query. If it fails, try with the next processor, if it succeeds, |
dcd9bc1d1bca
[ui] provide an autocomplete RQL bar (closes #2439846)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff
changeset
|
40 |
we're done and the RQL query will be executed. |
dcd9bc1d1bca
[ui] provide an autocomplete RQL bar (closes #2439846)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff
changeset
|
41 |