Skip to content

Commit 5220279

Browse files
committed
connector_typesense: refactor code
Implement a simple update of setting (I recommend to use typesense-dashbord for advanced config) Disable reindex and remove alias logic as it's complex and not needed, schema can be updated Reuse generic and add some specific typesense test
1 parent 5075edc commit 5220279

17 files changed

Lines changed: 11320 additions & 176 deletions

connector_typesense/README.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,9 @@ Search Engine > Configuration > Backends
5454
Usage
5555
=====
5656

57-
a nice UI is also available here: https://github.com/bfritscher/typesense-dashboard/releases
58-
57+
We recommend to use the typesense-dashboard for managing your typesense server.
58+
I will allow you to configure the mapping of index with a nice UI.
59+
Please take a look here: https://github.com/bfritscher/typesense-dashboard/releases
5960

6061
Bug Tracker
6162
===========
@@ -81,6 +82,7 @@ Contributors
8182

8283
* Maik Derstappen <md@derico.de>
8384
* Mohamed Alkobrosli <malkobrosly@kencove.com>
85+
* Sebastien BEAU <sebastien.beau@akretion.com>
8486

8587
Maintainers
8688
~~~~~~~~~~~

connector_typesense/__manifest__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
"data": [
1515
"views/ts_backend.xml",
1616
],
17-
"demo": ["demo/se_index_config_demo.xml", "demo/backend_demo.xml"],
18-
"external_dependencies": {"python": ["typesense==1.0.3", "requests"]},
17+
"demo": [
18+
"demo/backend_demo.xml",
19+
],
20+
"external_dependencies": {"python": ["typesense>=1.1.0", "requests"]},
1921
"installable": True,
2022
}

connector_typesense/demo/backend_demo.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
44
<odoo>
55
<record id="backend_1" model="se.backend">
6-
<field name="name">Demo Sale Channel Typesense</field>
7-
<field name="tech_name">demo_sale_channel_typesense</field>
6+
<field name="name">Demo Typesense Backend</field>
7+
<field name="tech_name">demo_typesense_backend</field>
88
<field name="backend_type">typesense</field>
9-
<field name="ts_server_host">localhost</field>
9+
<field name="ts_server_host">typesense</field>
1010
<field name="ts_server_port">8108</field>
1111
<field name="ts_server_protocol">http</field>
1212
<field name="ts_api_key">xyz</field>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
from . import se_backend, se_index
1+
from . import se_backend

connector_typesense/models/se_index.py

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
* Maik Derstappen <md@derico.de>
22
* Mohamed Alkobrosli <malkobrosly@kencove.com>
3+
* Sebastien BEAU <sebastien.beau@akretion.com>
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
a nice UI is also available here: https://github.com/bfritscher/typesense-dashboard/releases
2-
1+
We recommend to use the typesense-dashboard for managing your typesense server.
2+
I will allow you to configure the mapping of index with a nice UI.
3+
Please take a look here: https://github.com/bfritscher/typesense-dashboard/releases

connector_typesense/static/description/index.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,9 @@ <h1><a class="toc-backref" href="#toc-entry-2">Configuration</a></h1>
399399
</div>
400400
<div class="section" id="usage">
401401
<h1><a class="toc-backref" href="#toc-entry-3">Usage</a></h1>
402-
<p>a nice UI is also available here: <a class="reference external" href="https://github.com/bfritscher/typesense-dashboard/releases">https://github.com/bfritscher/typesense-dashboard/releases</a></p>
402+
<p>We recommend to use the typesense-dashboard for managing your typesense server.
403+
I will allow you to configure the mapping of index with a nice UI.
404+
Please take a look here: <a class="reference external" href="https://github.com/bfritscher/typesense-dashboard/releases">https://github.com/bfritscher/typesense-dashboard/releases</a></p>
403405
</div>
404406
<div class="section" id="bug-tracker">
405407
<h1><a class="toc-backref" href="#toc-entry-4">Bug Tracker</a></h1>
@@ -423,6 +425,7 @@ <h2><a class="toc-backref" href="#toc-entry-7">Contributors</a></h2>
423425
<ul class="simple">
424426
<li>Maik Derstappen &lt;<a class="reference external" href="mailto:md&#64;derico.de">md&#64;derico.de</a>&gt;</li>
425427
<li>Mohamed Alkobrosli &lt;<a class="reference external" href="mailto:malkobrosly&#64;kencove.com">malkobrosly&#64;kencove.com</a>&gt;</li>
428+
<li>Sebastien BEAU &lt;<a class="reference external" href="mailto:sebastien.beau&#64;akretion.com">sebastien.beau&#64;akretion.com</a>&gt;</li>
426429
</ul>
427430
</div>
428431
<div class="section" id="maintainers">
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import test_connector_typesense
Lines changed: 222 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,222 @@
1+
interactions:
2+
- request:
3+
body: null
4+
headers:
5+
Accept:
6+
- '*/*'
7+
Accept-Encoding:
8+
- gzip, deflate
9+
Connection:
10+
- keep-alive
11+
Content-Length:
12+
- '0'
13+
User-Agent:
14+
- python-requests/2.28.1
15+
X-TYPESENSE-API-KEY:
16+
- xyz
17+
method: DELETE
18+
uri: http://typesense:8108/collections/demo_typesense_backend_contact_en_us
19+
response:
20+
body:
21+
string: '{"created_at":1749219703,"default_sorting_field":"","enable_nested_fields":false,"fields":[{"facet":false,"index":true,"infix":false,"locale":"","name":"name","optional":false,"sort":false,"stem":false,"stem_dictionary":"","store":true,"type":"string"},{"facet":false,"index":true,"infix":false,"locale":"","name":"title","optional":false,"sort":false,"stem":false,"stem_dictionary":"","store":true,"type":"string"}],"name":"demo_typesense_backend_contact_en_us","num_documents":0,"symbols_to_index":[],"token_separators":[]}'
22+
headers:
23+
Connection:
24+
- keep-alive
25+
accept-ranges:
26+
- none
27+
access-control-allow-origin:
28+
- '*'
29+
content-length:
30+
- '525'
31+
content-type:
32+
- application/json; charset=utf-8
33+
transfer-encoding:
34+
- chunked
35+
vary:
36+
- accept-encoding
37+
status:
38+
code: 200
39+
message: OK
40+
- request:
41+
body: null
42+
headers:
43+
Accept:
44+
- '*/*'
45+
Accept-Encoding:
46+
- gzip, deflate
47+
Connection:
48+
- keep-alive
49+
User-Agent:
50+
- python-requests/2.28.1
51+
X-TYPESENSE-API-KEY:
52+
- xyz
53+
method: GET
54+
uri: http://typesense:8108/collections/demo_typesense_backend_contact_en_us
55+
response:
56+
body:
57+
string: '{"message": "Not Found"}'
58+
headers:
59+
Connection:
60+
- keep-alive
61+
access-control-allow-origin:
62+
- '*'
63+
content-type:
64+
- application/json; charset=utf-8
65+
transfer-encoding:
66+
- chunked
67+
status:
68+
code: 404
69+
message: Not Found
70+
- request:
71+
body: '{"fields": [{"name": "name", "type": "string"}], "name": "demo_typesense_backend_contact_en_us"}'
72+
headers:
73+
Accept:
74+
- '*/*'
75+
Accept-Encoding:
76+
- gzip, deflate
77+
Connection:
78+
- keep-alive
79+
Content-Length:
80+
- '96'
81+
User-Agent:
82+
- python-requests/2.28.1
83+
X-TYPESENSE-API-KEY:
84+
- xyz
85+
method: POST
86+
uri: http://typesense:8108/collections
87+
response:
88+
body:
89+
string: '{"created_at":1749219766,"default_sorting_field":"","enable_nested_fields":false,"fields":[{"facet":false,"index":true,"infix":false,"locale":"","name":"name","optional":false,"sort":false,"stem":false,"stem_dictionary":"","store":true,"type":"string"}],"name":"demo_typesense_backend_contact_en_us","num_documents":0,"symbols_to_index":[],"token_separators":[]}'
90+
headers:
91+
Connection:
92+
- keep-alive
93+
access-control-allow-origin:
94+
- '*'
95+
content-type:
96+
- application/json; charset=utf-8
97+
transfer-encoding:
98+
- chunked
99+
status:
100+
code: 201
101+
message: Created
102+
- request:
103+
body: '{"id": "1", "name": "foo"}
104+
105+
{"id": "2", "name": "bar"}
106+
107+
{"id": "3", "name": "joe"}'
108+
headers:
109+
Accept:
110+
- '*/*'
111+
Accept-Encoding:
112+
- gzip, deflate
113+
Connection:
114+
- keep-alive
115+
Content-Length:
116+
- '80'
117+
User-Agent:
118+
- python-requests/2.28.1
119+
X-TYPESENSE-API-KEY:
120+
- xyz
121+
method: POST
122+
uri: http://typesense:8108/collections/demo_typesense_backend_contact_en_us/documents/import?action=upsert
123+
response:
124+
body:
125+
string: '{"success":true}
126+
127+
{"success":true}
128+
129+
{"success":true}'
130+
headers:
131+
Connection:
132+
- keep-alive
133+
accept-ranges:
134+
- none
135+
access-control-allow-origin:
136+
- '*'
137+
content-length:
138+
- '50'
139+
content-type:
140+
- text/plain; charset=utf-8
141+
transfer-encoding:
142+
- chunked
143+
vary:
144+
- accept-encoding
145+
status:
146+
code: 200
147+
message: OK
148+
- request:
149+
body: null
150+
headers:
151+
Accept:
152+
- '*/*'
153+
Accept-Encoding:
154+
- gzip, deflate
155+
Connection:
156+
- keep-alive
157+
Content-Length:
158+
- '0'
159+
User-Agent:
160+
- python-requests/2.28.1
161+
X-TYPESENSE-API-KEY:
162+
- xyz
163+
method: DELETE
164+
uri: http://typesense:8108/collections/demo_typesense_backend_contact_en_us/documents/?filter_by=id%3A%5B1%2C+2%5D
165+
response:
166+
body:
167+
string: '{"num_deleted":2}'
168+
headers:
169+
Connection:
170+
- keep-alive
171+
accept-ranges:
172+
- none
173+
access-control-allow-origin:
174+
- '*'
175+
content-length:
176+
- '17'
177+
content-type:
178+
- application/json
179+
transfer-encoding:
180+
- chunked
181+
vary:
182+
- accept-encoding
183+
status:
184+
code: 200
185+
message: OK
186+
- request:
187+
body: null
188+
headers:
189+
Accept:
190+
- '*/*'
191+
Accept-Encoding:
192+
- gzip, deflate
193+
Connection:
194+
- keep-alive
195+
User-Agent:
196+
- python-requests/2.28.1
197+
X-TYPESENSE-API-KEY:
198+
- xyz
199+
method: GET
200+
uri: http://typesense:8108/collections/demo_typesense_backend_contact_en_us/documents/search?per_page=250&q=%2A&page=1
201+
response:
202+
body:
203+
string: '{"facet_counts":[],"found":1,"hits":[{"document":{"id":"3","name":"joe"},"highlight":{},"highlights":[]}],"out_of":1,"page":1,"request_params":{"collection_name":"demo_typesense_backend_contact_en_us","first_q":"*","per_page":250,"q":"*"},"search_cutoff":false,"search_time_ms":0}'
204+
headers:
205+
Connection:
206+
- keep-alive
207+
accept-ranges:
208+
- none
209+
access-control-allow-origin:
210+
- '*'
211+
content-length:
212+
- '280'
213+
content-type:
214+
- application/json; charset=utf-8
215+
transfer-encoding:
216+
- chunked
217+
vary:
218+
- accept-encoding
219+
status:
220+
code: 200
221+
message: OK
222+
version: 1

0 commit comments

Comments
 (0)