Created
December 17, 2014 17:41
-
-
Save Kevinlearynet/c1ca04a6faa2c3f06bb0 to your computer and use it in GitHub Desktop.
Example of using 'solr-client' in Node.js environment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// install solr client package: `npm install solr --save` | |
var solr = require( 'solr-client' ); | |
// client connects to solr host | |
var client = solr.createClient({ | |
host : host, | |
port : port, | |
core : core, | |
path : path, | |
agent : agent, | |
secure : secure, | |
bigint : bigint | |
}); | |
// search query (DixMax) | |
var query = client.createQuery() | |
.q( '%keywords%' ) | |
.dismax() | |
.qf( { | |
title_t: 0.2, | |
description_t: 3.3 | |
} ) | |
.mm( 2 ) | |
.start( 0 ) | |
.rows( 10 ); | |
// run search | |
client.search( query, function ( err, obj ) { | |
if ( err ) { | |
console.log( err ); | |
} else { | |
console.log( obj ); | |
} | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment