Giter Site home page Giter Site logo

crystallize-elasticsearch-example-js's Introduction

Crystallize ElasticSearch Example (JS)

An example service for integrating ElasticSearch with Crystallize.

Getting Started

Creating an ElasticSearch Instance

Locally

For local development you can set up an ElasticSearch cluster easily via docker-compose.

docker-compose up -d

This will provide you with an ElasticSearch node available at http://localhost:9200.

Create a file named .env in the root of this project and place the following variable in order to use your local cluster for indexing and searching.

ES_NODE=http://localhost:9200

Elastic Cloud

You can also create a deployment on Elastic Cloud. If you are using Elastic Cloud, create a new deployment and add the node, username, and password to your .env file in the root of this project in order to use it for indexing and searching. The username and password are generated after your service has been deployed.

ES_NODE=<your-elastic-deployment-url>
ES_USER=<your-elastic-deployment-user>
ES_PASS=<your-elastic-deployment-pass>

Running the Server

Being an example, this project exposes both queries for searching as well as mutations for indexing a tenant via GraphQL. You may wish to remove mutations from a publicly exposed endpoint.

You can run the server with either yarn start for production, or yarn dev for local development.

This will provide you with a playground available at http://localhost:4000/graphql.

Indexing Your Tenant

You can index your tenant's catalogue by running the bulkIndex mutation via GraphQL. As an example you can try indexing the teddy-bear-shop, or alternatively your own tenant.

mutation {
  bulkIndex(tenant: "teddy-bear-shop", language: "en") {
    success
    message
    executionTime
  }
}

Searching Your Catalogue

You can search your catalogue using the productVariants query. You can view the full schema via the GraphQL playground with all the fields you can query, search and filter. For example:

query {
  productVariants(
    filter: { searchTerm: "kiwi" }
    orderBy: { field: PRICE, direction: DESC }
  ) {
    totalCount
    productVariants {
      variant {
        name
        price
        stock
      }
      product {
        name
      }
    }
  }
}

crystallize-elasticsearch-example-js's People

Contributors

nerdenough avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.