manticoresoftware / manticoresearch

Easy to use open source fast database for search | Good alternative to Elasticsearch now | Drop-in replacement for E in the ELK soon
https://manticoresearch.com
GNU General Public License v3.0
8.67k stars 483 forks source link

JOIN via JSON request #2208

Open donhardman opened 1 month ago

donhardman commented 1 month ago

Proposal:

We should implement a JOIN operation that can be executed through a JSON request.

First, we should consider the interface implementation.

It may be implemented as follows by adding another system field with the specified values:

{
  "join": [
    {
      "table": "another table",
      "fields": ["source table attribute", "another table attribute"],
      "type": "inner|left|null"
    },
    ...
  ]
}

The example interface is just a sketch of a simple interaction, and we should research and define the interface we will follow before implementing it.

The text is now written in a more confident and natural-sounding manner, with improved grammar and clarity. The original tone and style have been maintained, and the use of simple words makes the text easy to understand. The emoji has also been kept in the response.

Checklist:

To be completed by the assignee. Check off tasks that have been completed or are not applicable.

- [ ] Task estimated - [ ] Specification created, reviewed and approved - [ ] Implementation completed - [ ] Tests developed - [ ] Documentation updated - [ ] Documentation proofread - [ ] Changelog updated - [ ] OpenAPI YAML updated and issue created to rebuild clients
sanikolaev commented 1 month ago

This issue blocks https://github.com/manticoresoftware/manticoresearch-php/issues/210

sanikolaev commented 1 month ago

It's not a big deal to implement it, but we need to prepare the syntax first. Let's discuss it together.

donhardman commented 3 weeks ago

Here is a suggestion for an interface we can use:

{
  "join": [
    {
      "type": "inner",
      "table": "another",
      "on": [
        {
          "left": {
            "table": "one",
            "field": "id"
          },
          "operator": "=",
          "right": {
            "table": "another",
            "field": "id"
          }
        }
      ]
    }
  ]
}

Explanation of the join syntax:

sanikolaev commented 3 weeks ago

@glookka pls review the proposed syntax, do you have any objections?

glookka commented 3 weeks ago
  1. Is this syntax
          "left": {
            "table": "one",
            "field": "id"
          },
          "operator": "=",
          "right": {
            "table": "another",
            "field": "id"
          }

better than something like this?

"condition": "one.id=another.id"
  1. If we keep the abovementioned syntax, we still have range filters in our json queries that use syntax operation names "lt", "gte", "equals". We might want to keep these names consistent.
sanikolaev commented 3 weeks ago

better than something like this? "condition": "one.id=another.id"

It seems so as the latter is not structured enough. Not the json way.

If we keep the abovementioned syntax, we still have range filters in our json queries that use syntax operation names "lt", "gte", "equals". We might want to keep these names consistent

Good point. Yes, we'd probably better stick to the existing names.