Giter VIP home page Giter VIP logo

node-solr-lambda's Introduction

node-solr-lambda

Conventional Commits

Features

  • functional-style API with jsdoc type annotations
  • plain javascipt in commonjs format - no additional build step required
  • ES6+ including async/await, lambdas, spread operator...
  • typechecking support in vscode (without compiling typescript code)
  • no runtime dependencies other than axios
  • as close as possible to the Solr Json-based REST API
  • functions for working with documents, fields, field types, cores

Example

const { prepareSolrClient } = require("node-solr-lambda");
const solr = prepareSolrClient("mycore");

async function myfun() {
  const result = await solr.query({ query: "label:something" });
  console.log(result);

  await solr.addField({ name: "price", type: "plong", multiValued: false });
  await solr.addField({
    name: "category",
    type: "string",
    multiValued: true,
    docValues: true
  });

  const item1 = { id: "item1", price: 123, category: ["cpu", "ram"] };
  const item2 = { id: "item2", price: 456, category: ["cpu", "usb"] };
  await solr.add(item1); // works with single object
  await solr.add([item1, item2]); // works with object[]
  await solr.commit()

  await solr.query({
    query: "*:*",
    facet: {
      top_5_categories: {
        terms: {
          field: "category",
          limit: 5,
          facet: {
            avg_price: "avg(price)"
          }
        }
      }
    }
  });
}

How to test

We provide a docker-compose with a solr instance for testing. The testing solr instance needs to run first:

# run this in a separate terminal and shutdown using CTRL+C
yarn test:prepare

Now you can run the test suite:

yarn test

node-solr-lambda's People

Contributors

dependabot[bot] avatar vsimko avatar

Stargazers

 avatar

Watchers

 avatar  avatar

node-solr-lambda's Issues

add query builder

In select function the parameters for solr are now passed as an object, e.g. as follow:

const solr = require('node-solr-lambda').prepareSolrClient()
const results = await solr.select({
  q: 'label:test',
  sort: 'label desc',
  core: 'my_core'
})

It would be nice to have a builder function that creates the parameters in a more convenient way. For example by making use of intellisense in vscode:

const {prepareSolrClient, query} = require('node-solr-lambda')
const solr = prepareSolrClient()
const params = query('label:test').sort('label').desc()
const results = await solr.select(params, 'my_core')

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.