Package: oceandb-elasticsearch-driver
oceandb-elasticsearch-driver🐳Elasticsearchdriver for OceanDB (Python).oceanprotocol.comTable of ContentsFeaturesPrerequisitesQuickstartEnvironment variablesQueriesFeaturesElasticsearch driver to connect implementing OceanDB.PrerequisitesYou should have running a elasticsearch instance.QuickstartFirst 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/configIf 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[oceandb]enabled=true# In order to enable or not the pluginmodule=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=oceandb# Elasticsearch index nameOnce you have defined this the only thing that you have to do it is use it:oceandb=OceanDb(conf)oceandb.write({"value":"test"},id)Environment variablesWhen you want to instantiate an Oceandb plugin you can provide the next environment variables:$CONFIG_PATH$MODULE$DB_HOSTNAME$DB_PORT$DB_INDEX$DB_USERNAME$DB_PASSWORDQueriesYou can query the DDO using predefined fields or provide the path to the desired fields yourself.All queries use a common format:{"query":{"field":["value1","value2"]}}Querying predefined fieldsPredefined fields include:costCould 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:{"cost":[0,10]}It is transformed to:{"service.attributes.main.cost":{"$gt": 0, "$lt": 10}}licenseIt 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"]}typeIt is going to check that the following service types are included in the ddo.{"type":["Access", "Metadata"]}sampleCheck that the metadata include a sample that contains a link of type sample. Do not take parameters.{"sample":[]}categoriesRetrieve all the values that contain one of the specifies categories.{"categories":["weather", "meteorology"]}createdRetrieve all the values that has been created between two dates.{"created":['2016-02-07T16:02:20Z', '2016-02-09T16:02:20Z']}dateCreatedRetrieve all the values that has been created between two dates.{"dateCreated":['2016-02-07T16:02:20Z', '2016-02-09T16:02:20Z']}datePublishedRetrieve all the values that has been published between two dates.{"datePublished":['2016-02-07T16:02:20Z', '2016-02-09T16:02:20Z']}updatedFrequencyRetrieve 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"]}Querying custom fields as textsYou can also query the DDO by value of any field. To do that, you will need to provide the full path inside the metadata instead of just the field name.For example:{"query":{"service.attributes.additionalInformation.customField":["customValue1","customValue2"]}}Querying custom fields as intervalsTo do that, you will need to provide the full path inside the metadata instead of just the field name, and values as integers or floatsFor example:{"query":{"service.attributes.additionalInformation.customNumber":[3,6]}}which is translated to:{"bool":{"must":[{"bool":{"should":[{"range":{"service.attributes.additionalInformation.customNumber":{"gte":3,"lte":6}}}]}}]}}Code styleThe information about code style in python is documented in this two linkspython-developer-guideandpython-style-guide.TestingAutomatic tests are setup via Travis, executingtox.
Our test use pytest framework.New VersionThebumpversion.shscript helps to bump the project version. You can execute the script using as first argument {major|minor|patch} to bump accordingly the version.LicenseCopyright 2018 Ocean Protocol Foundation Ltd.

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.