Loopback4 connect to Elasticsearch
Asked Answered
F

0

7

How to connect loopback4 server app with Elasticsearch DB.

I have tried with below reference links. but they have not explained for loopback4. And have did same implementation using below references but not able creating mapping properly to fetch records.

https://loopback.io/doc/en/community/Elasticsearch-connector.html

https://github.com/strongloop-community/loopback-connector-elastic-search/tree/feature/esv6

{
  "name": "customer",
  "connector": "esv6",
  "index": "index_name",
  "hosts": [
    {
      "protocol": "http",
      "host": "127.0.0.1",
      "port": 9200
    }
  ],
  "apiVersion": "6.5",
  "defaultSize": "100",
  "requestTimeout": 30000,
  "log": "trace",
  "mappingType": "basedata",
  "mappings": [],
  "mappingProperties": {
    "......."
    "id": {
      "type": "keyword",
      "index": true
    },
    "docType": {
      "type": "keyword",
      "index": true
    }
  }
 }
}

And my model having same id property like this

@property({
    type: "string",
    id: true,
    generated: true,
  })
  id: string;

using => "loopback-connector-esv6": "^1.3.0"

i am able to create (POST) a model object with auto generated id (_id).. but using this id/_id, we are not able to GET find/fetch any data. except create (POST) other APIS are not working..

So could you please suggest to help on this .. how to mapping model properties to Elasticsearch DB using loopback4.

Freezedrying answered 25/3, 2019 at 13:16 Comment(1)
Any error messages generated?Sandusky

© 2022 - 2024 — McMap. All rights reserved.