Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 108 additions & 0 deletions connector_typesense/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
===================
connector_typesense
===================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:f09633c3af59b153f0eba3f876a9835676c430a6f39dd0dfa3545a924c80bc11
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fsearch--engine-lightgray.png?logo=github
:target: https://github.com/OCA/search-engine/tree/16.0/connector_typesense
:alt: OCA/search-engine
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/search-engine-16-0/search-engine-16-0-connector_typesense
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/search-engine&target_branch=16.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This addon provides the bases to implement addons to export information to
Typesense_ indexes.

.. _Typesense: https://typesense.org

**Table of contents**

.. contents::
:local:

Installation
============

This package requires a typesense search engine running.
Please read this for a [quick docker based setup](https://typesense.org/docs/guide/install-typesense.html#option-2-local-machine-self-hosting).

Configuration
=============

You have to configure (Host, Port, Protocol, Typesense API Key) in a new backend form view:

Search Engine > Configuration > Backends

Usage
=====

a nice UI is also available here: https://github.com/bfritscher/typesense-dashboard/releases


Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/search-engine/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/search-engine/issues/new?body=module:%20connector_typesense%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* Derico
* Kencove

Contributors
~~~~~~~~~~~~

* Maik Derstappen <md@derico.de>
* Mohamed Alkobrosli <malkobrosly@kencove.com>

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

.. |maintainer-Kencove| image:: https://github.com/Kencove.png?size=40px
:target: https://github.com/Kencove
:alt: Kencove

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-Kencove|

This module is part of the `OCA/search-engine <https://github.com/OCA/search-engine/tree/16.0/connector_typesense>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 2 additions & 0 deletions connector_typesense/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import models
from . import tools
20 changes: 20 additions & 0 deletions connector_typesense/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2024 Derico
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "connector_typesense",
"category": "Connector",
"summary": "Connector For Typesense Search Engine",
"version": "16.0.1.0.0",
"license": "AGPL-3",
"author": "Derico, Kencove, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/search-engine",
"maintainers": ["Kencove"],
"depends": ["connector_search_engine"],
"data": [
"views/ts_backend.xml",
],
"demo": ["demo/se_index_config_demo.xml", "demo/backend_demo.xml"],
"external_dependencies": {"python": ["typesense==1.0.3", "requests"]},
"installable": True,
}
14 changes: 14 additions & 0 deletions connector_typesense/demo/backend_demo.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2025 Kencove
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<odoo>
<record id="backend_1" model="se.backend">
<field name="name">Demo Sale Channel Typesense</field>
<field name="tech_name">demo_sale_channel_typesense</field>
<field name="backend_type">typesense</field>
<field name="ts_server_host">localhost</field>
<field name="ts_server_port">8108</field>
<field name="ts_server_protocol">http</field>
<field name="ts_api_key">xyz</field>
</record>
</odoo>
22 changes: 22 additions & 0 deletions connector_typesense/demo/se_index_config_demo.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="se_index_config_product" model="se.index.config">
<field name="name">TS Product Config</field>
<field name="body">{}</field>
<field name="body_str">
{
"name": "ts_products_collection",
"fields": [
{
"name": "id",
"type": "string"
},
{
"name": "name",
"type": "string"
}
]
}
</field>
</record>
</odoo>
1 change: 1 addition & 0 deletions connector_typesense/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import se_backend, se_index
43 changes: 43 additions & 0 deletions connector_typesense/models/se_backend.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Copyright 2024 Derico
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields, models

from ..tools.adapter import TypesenseAdapter


class SeBackend(models.Model):
_inherit = "se.backend"

backend_type = fields.Selection(
selection_add=[("typesense", "Typesense")],
ondelete={"typesense": "cascade"},
string="Type",
required=True,
)
ts_server_host = fields.Char(
string="Typesense host",
groups="connector_search_engine.group_connector_search_engine_manager",
Comment thread
kobros-tech marked this conversation as resolved.
)
ts_server_port = fields.Char(
string="Typesense port",
groups="connector_search_engine.group_connector_search_engine_manager",
)
ts_server_protocol = fields.Char(
string="Typesense protocol",
groups="connector_search_engine.group_connector_search_engine_manager",
)
ts_server_timeout = fields.Integer(
string="Typesense server timeout",
groups="connector_search_engine.group_connector_search_engine_manager",
)
ts_api_key = fields.Char(
help="Typesense Api Key",
groups="connector_search_engine.group_connector_search_engine_manager",
)

def _get_adapter_class(self):
if self.backend_type == "typesense":
return TypesenseAdapter
else:
return super()._get_adapter_class()

Check warning on line 43 in connector_typesense/models/se_backend.py

View check run for this annotation

Codecov / codecov/patch

connector_typesense/models/se_backend.py#L43

Added line #L43 was not covered by tests
19 changes: 19 additions & 0 deletions connector_typesense/models/se_index.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2024 Derico
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields, models

from ..tools.serializer import TSJsonifySerializer


class SeIndex(models.Model):

_inherit = "se.index"

serializer_type = fields.Selection(selection_add=[("typesense", "Typesense")])

def _get_serializer(self):
if self.serializer_type == "typesense":
return TSJsonifySerializer()
else:
return super()._get_serializer()

Check warning on line 19 in connector_typesense/models/se_index.py

View check run for this annotation

Codecov / codecov/patch

connector_typesense/models/se_index.py#L19

Added line #L19 was not covered by tests
Comment on lines +13 to +19
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It do not make sense to add a serializer here.
Serializer are not "linked" to a kind of search engine, but more on a kind of usage "shopinvader" for example.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shopinvader is doing the same by the way in its custom modules

but I am not following shopinvader as it looks old technique and hard code serialzing but I do dynamic serialzing.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it will better to add a "dynamic serialer" in a separated module, because the serializer is not related to typesense (it can be used for other search engine

Copy link
Copy Markdown
Contributor

@lmignon lmignon Jun 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shopinvader is doing the same by the way in its custom modules

but I am not following shopinvader as it looks old technique and hard code serialzing but I do dynamic serialzing.

@kobros-tech

old technique 🤔 We follow a different pattern but not an old technique since in v8 we started with dynamic serializing using the base_jsonify... The uses of pre-defined models is motivated by:

  • the need to control the format and the content exported to the search engine to avoid any leak of information. * the need to provide the documentation related to the data exported
  • define a strict contract between Odoo and ES (If the internal model of odoo evolve when migrating from one version to another, we are sure to not break the website since the mapping is explicit and our unittest will fails)
  • ...

There are no old and new or right and wrong approaches. It all depends on individual needs and sensitivities. With this in mind, the architecture of these modules has been designed to allow easy adaptation to individual needs.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am sorry, I can't compare one single module to a project :)

3 changes: 3 additions & 0 deletions connector_typesense/readme/CONFIGURE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
You have to configure (Host, Port, Protocol, Typesense API Key) in a new backend form view:

Search Engine > Configuration > Backends
2 changes: 2 additions & 0 deletions connector_typesense/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* Maik Derstappen <md@derico.de>
* Mohamed Alkobrosli <malkobrosly@kencove.com>
4 changes: 4 additions & 0 deletions connector_typesense/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
This addon provides the bases to implement addons to export information to
Typesense_ indexes.

.. _Typesense: https://typesense.org
2 changes: 2 additions & 0 deletions connector_typesense/readme/INSTALL.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This package requires a typesense search engine running.
Please read this for a [quick docker based setup](https://typesense.org/docs/guide/install-typesense.html#option-2-local-machine-self-hosting).
2 changes: 2 additions & 0 deletions connector_typesense/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
a nice UI is also available here: https://github.com/bfritscher/typesense-dashboard/releases

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading