Skip to main content

🐳 Metadata ElasticSearch Driver (Python).

Project description

banner

metadata-driver-elasticsearch

🐳 Elasticsearch driver for MetadataDB (Python). nevermined.io

PyPI Python package


Table of Contents


Features

Elasticsearch driver to connect implementing MetadataDB.

Prerequisites

You should have running a elasticsearch instance.

Quickstart

First of all we have to specify where is allocated our config. To do that we have to pass the following argument:

--config=/path/of/my/config

If you do not provide a configuration path, by default the config is expected in the config folder.

In the configuration we are going to specify the following parameters to

    [metadatadb]

    enabled=true            # In order to enable or not the plugin
    module=elasticsearch    # You can use one the plugins already created. Currently we have elasticsearch, mongodb and bigchaindb.
    module.path=            # You can specify the location of your custom plugin.
    db.hostname=localhost   # Address of your Elasticsearch instance.
    db.port=9200            # Port of your Elasticsearch rest API.
    db.username=elastic     # If you are using authentication, elasticsearch username.
    db.password=changeme    # If you are using authentication, elasticsearch password.
    db.index=metadatadb     # Elasticsearch index name

Once you have defined this the only thing that you have to do it is use it:

    metadatadb = MetadataDB(conf)
    metadatadb.write({"value": "test"}, id)

Environment variables

When you want to instantiate an Metadatadb plugin you can provide the next environment variables:

  • $CONFIG_PATH
  • $MODULE
  • $DB_HOSTNAME
  • $DB_PORT
  • $DB_INDEX
  • $DB_USERNAME
  • $DB_PASSWORD

Queries

Currently we are supporting a list of queries predefined in order to improve the search: All this queries present a common format: query:{"name":[args]}

This queries are the following:

  • price

    Could receive one or two parameters. If you only pass one assumes that your query is going to start from 0 to your value.

    Next query: query:{"price":[0,10]}

    It is transformed to: {"service.metadata.base.price":{"$gt": 0, "$lt": 10}}

  • license

    It is going to retrieve all the documents with license that you are passing in the parameters, if you do not pass any value retrieve all.

    {"license":["Public domain", "CC-YB"]}

  • type

    It is going to check that the following service types are included in the ddo.

    {"type":["Access", "Metadata"]}

  • sample

    Check that the metadata include a sample that contains a link of type sample. Do not take parameters.

    {"sample":[]}

  • categories

    Retrieve all the values that contain one of the specifies categories.

    {"categories":["weather", "meteorology"]}

  • created

    Retrieve all the values that has been created between two dates.

    {"created":['2016-02-07T16:02:20Z', '2016-02-09T16:02:20Z']}

  • dateCreated

    Retrieve all the values that has been created between two dates.

    {"dateCreated":['2016-02-07T16:02:20Z', '2016-02-09T16:02:20Z']}

  • datePublished

    Retrieve all the values that has been published between two dates.

    {"datePublished":['2016-02-07T16:02:20Z', '2016-02-09T16:02:20Z']}

  • updatedFrequency

    Retrieve all the values that contain one of the specifies updated frecuencies.

    {"updatedFrequency":["monthly"]}

  • text Retrieve all the values that match with the text sent.

    {"text":["weather"]}

  • did Retrieve all the matching dids.

    {"did":["did:nv:1..,did:nv:2.."]}

Testing

Automatic tests are setup via Github actions. Our test use pytest framework.

New Version

The bumpversion.sh script helps to bump the project version. You can execute the script using as first argument {major|minor|patch} to bump accordingly the version.

License

Copyright 2020 Keyko GmbH
This product includes software developed at
BigchainDB GmbH and Ocean Protocol (https://www.oceanprotocol.com/)

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Built Distribution

File details

Details for the file nevermined-metadata-driver-elasticsearch-0.1.6.tar.gz.

File metadata

  • Download URL: nevermined-metadata-driver-elasticsearch-0.1.6.tar.gz
  • Upload date:
  • Size: 20.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

File hashes

Hashes for nevermined-metadata-driver-elasticsearch-0.1.6.tar.gz
Algorithm Hash digest
SHA256 2d0e377e7f725d2bfcbb4b5ff98734d58a5b3d512265424993ca1ba7ad8b48b6
MD5 f37b613412000ba22e17c690796dfbfb
BLAKE2b-256 ec27ae10f07305bd37569dcd79ca4fd503ede06661383ccd45f915d987e7f835

See more details on using hashes here.

File details

Details for the file nevermined_metadata_driver_elasticsearch-0.1.6-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for nevermined_metadata_driver_elasticsearch-0.1.6-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 bbb52f830ce2e491b08e5d88e3bd5bef7217790d38608c480a9b9d1246036533
MD5 ae0cd618507bae98e3769942370d9c21
BLAKE2b-256 04fd11d3a61eb5e23cf9b7e8830f640df733448ccff1b01a790bb96ac57c5c0c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page