noelrivasc / sails-solr

Solr adapter for Sails
Other
5 stars 2 forks source link

Doesn't work on existing databases #5

Open ca0abinary opened 7 years ago

ca0abinary commented 7 years ago
Node v3.10.7
Sails v0.12.6
sails-solr v0.1.4
mac os x 10.12

When performing a find on an existing solr database (one not created with sails-solr) the query is appended with fq: 'modelname:"<modelname>"' which results in solr returning the error undefined field <modelname>

connections: {
    solrDb: {
      adapter: 'sails-solr',
      host: 'localhost',
      core: 'myExistingCore',
      schema: false,
      manageCores: false
    }
  }
module.exports = {
    identity: 'product',
    connection: 'solrDb',

    attributes: {
        "ProductID": { type: 'integer' },
        "IsInStock": { type: 'boolean' },
        "Description": { type: 'string' }
    }
}

Is there a way without setting single: true to remove the fq: 'modelname:"product"' from the query? When single is set to true node crashes with the following exception:

sails-solr/lib/collection.js:730
    _.each(self.collections[collection].definition, function(field) {
                                       ^

TypeError: Cannot read property 'definition' of undefined
    at Collection._parseDocuments (/Users/jdemarks/code/sails-test/backend/node_modules/sails-solr/lib/collection.js:730:40)
    at Collection._findResponse (/Users/jdemarks/code/sails-test/backend/node_modules/sails-solr/lib/collection.js:413:29)
    at /Users/jdemarks/code/sails-test/backend/node_modules/sails-solr/lib/collection.js:394:39
    at DestroyableTransform.<anonymous> (/Users/jdemarks/code/sails-test/backend/node_modules/solr-hyperquest-client/lib/client.js:471:28)
    at emitNone (events.js:91:20)
    at DestroyableTransform.emit (events.js:185:7)
    at /Users/jdemarks/code/sails-test/backend/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:965:16
    at _combinedTickCallback (internal/process/next_tick.js:67:7)
    at process._tickDomainCallback (internal/process/next_tick.js:122:9)
sajov commented 7 years ago

Hi will Check that in the next days