# solr-query

> An attempt to make solr searches a little more user-friendly

Latest version **0.2.1** (published 2018-01-27) · ISC license · 0 weekly downloads

## Install

```sh
npm install solr-query
pnpm add solr-query
yarn add solr-query
bun add solr-query
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.1 |
| Published | 2018-01-27 |
| First published | 2017-07-18 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 (+10 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Matthew Young |
| Maintainers | mashu.daishi |

## Links

- npm: https://www.npmjs.com/package/solr-query
- Repository: https://github.com/mashu-daishi/solr-query
- Homepage: https://github.com/mashu-daishi/solr-query#readme
- Issues: https://github.com/mashu-daishi/solr-query/issues
- npm.io page: https://npm.io/package/solr-query

## Dependencies (2)

- [lodash](https://npm.io/package/lodash.md) 4.17.4
- [request](https://npm.io/package/request.md) 2.81.0

## Recent versions

- 0.2.1 (latest) — 2018-01-27
- 0.1.1 — 2017-08-17
- 0.1.0 — 2017-07-31
- 0.0.2 — 2017-07-18

## README

# solr-query

This project is an attempt at making Solr searches a little easier. I'm sure I'm not the only person that's struggled with trying to build a correct query string for Solr.

### Notes

This is an in-progress project. For now, only Solr /search and /update is supported.

## Installing

```
npm install solr-query
```

```js
const Client = require( 'solr-query' );

const solrC = new Client();

solrC.search( searchQuery, searchOptions );

newRequest.save( obj )
.then( data => {
	console.log( "data:", data );
} ).catch( err => {
	console.log( "err:", err );
} );
```

## Methods

### Solr Configuration

When spawning a new Client object, you may pass in options to connect to your instance of Solr. The optional parameters are listed in the [config folder](https://github.com/mashu-daishi/solr-query).

### .search( searchQuery, searchOptions )
##### searchQuery

This will accept a variety of options. It can be a string, an array, or an object. There are a combination of possibilities with Objects. If your search query is: ```q=Money AND (USD OR GBP)```, you can pass an object of:
```js
searchQuery = {
    '$and' : [ 'Money', { '$or' : [ 'USD', 'GBP' ] } ]
}
```

##### searchOptions

```options.logging( function );```
( You may pass in any function, or ```console.log``` to print to console.)
This will output the ```request``` object that will be sent. It should allow you to see the ```URL```, ```Method```, and ```qs``` parameters.

```options.commonParams```
This is where you would pass in any solr-specific query parameters that do not need formatted.

For example:
```?qf=contents&limit=100```
would be passed as
```js
options.commonParams = {
    'qf'    : 'contents',
    'limit' : 100
};
```
Please note, if you pass a `q` parameter into this, it **will** override the `searchQuery` that is passed in.

### .save( solrObj )
##### solrObj

This currently accepts a json object that will be entered verbatim into Solr.
```js
solrObj = {
	"title" : "Kinda Cool",
	"uid"   : "b5546172-713a-44f8-9105-761158ca75d9"
}
```

## Running the tests

```
npm test
```

## Authors

* **Matthew Young** - *Initial work* - [mashu-daishi](https://github.com/mashu-daishi)

---
_Source: https://npm.io/package/solr-query · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
