zincsearch / zincsearch

ZincSearch . A lightweight alternative to elasticsearch that requires minimal resources, written in Go.
https://zincsearch-docs.zinc.dev
Other
16.91k stars 731 forks source link

Feature request: Optional predefined indexMapping type #67

Closed sbruggmann closed 2 years ago

sbruggmann commented 2 years ago

In some cases it's required to have a string indexed as keyword instead of just text.

Could be solved like this in a single record:

data = {
    "Athlete": "DEMTSCHENKO, Albert",
    "Country": {
        "mapping": "keyword",
        "value": "RUS"
    },
    // ..
  }

Or like this in a bulk ingestion file:

{ "index" : { "_index" : "olympics" } }
{"Athlete": "HAJOS, Alfred", "Country": {"mapping": "keyword", "value": "HUN"}, /* .. */}
bbkane commented 2 years ago

I think this is the same as my request at https://zinc-nvh4832.slack.com/archives/C02QT4HCJ5P/p1642328076031900

sbruggmann commented 2 years ago

@bbkane :+1: The automatic type definition is great for simple data, but there needs to be an optional solution to define the types manually.

sbruggmann commented 2 years ago

I rethinked the proposed mapping configuration. Of course it should follow the ES structure and we could say:

Endpoint: PUT /api/index

Payload without specific mapping:

{
    "name": "myshinynewindex",
    "storage_type": "disk"
}

Payload with specific mapping:

{
    "name": "myshinynewindex",
    "storage_type": "disk",
    "mappings": {
        "properties": {
            "author": {
                "type": "text"
            },
            "identifier": {
                "type:": "keyword"
            }
        }
    }
}

This way it should be a rather small change in CreateIndex endpoint and a change in the indexer to not update the mapping if it was set manually upfront.

hengfeiyang commented 2 years ago

implemented at #71

prabhatsharma commented 2 years ago

Released in https://github.com/prabhatsharma/zinc/releases/tag/v0.1.5