Using Solr for indexing and search with Mongodb and nodejs - node.js

Does anyone have any experience with this particular stack? I'm working on a web project that will eventually contain an extremely large amount of data and was trying to get Solr to play nicely with some simple Mongodb entries but I have found little to no information about it. I found this: http://blog.knuthaugen.no/2010/04/cooking-with-mongodb-and-solr.html which is mongodb + solr + php, but I'm struggling to see how I would use node similarly. Anybody have any insight? I'd greatly appreciate it. If this is a dumb thing to try to implement, feel free to let me know as well!
Found this library: https://github.com/tjgillies/node-lucene
Doesn't look like there is much documentation there but I'll give it a go.
Update:
So a quick fix (not ideal) that worked was to use a Perl module for lucene and then using the child process functionality in Node.js, I was able to insert and search for my data inside of lucene. So for a workaround, it does the trick.

Probably as of Sep 2012, you would want to take a look at this.
https://github.com/lbdremy/solr-node-client
Good documentations http://lbdremy.github.com/solr-node-client/ (though I didnt liked the web fonts used) but seems VERY promising.

This project looks promising: https://github.com/gsf/node-solr. Not a whole lot of docs, but the tests are promisingly descriptive.
Then you would maybe do something like this in your mongoose schema:
schema.pre('save', function (next) {
// this will be triggered when your mongoose schema object is saved
// TODO add to a queue that sends the documents to SOLR in e.g. batches
// of 2000
});
http://mongoosejs.com/docs/middleware.html
I've been wanting to try mongo + SOLR + node but haven't started any coding yet.

Related

Graphql, way to organize entities into tree shema

Yo hello,
pretty new into graphQl game, but I was wondering, is there way how to organize entities into tree schema similar to how swagger doing it? Using apollo server for UI/ debbuging of my graphQl.
Somehow turn this:
Into this:
Thanks for any help or suggestions...
Using it on nodejs/ typescript, grapql, graphql-modules, prisma... Dunno if it's important.
I dont think it is possible with current graphQL schema specification.
You can try using this instrument to convert grapqhQL to openApi schema, and then edit it to add grouping. It is hardly a good solution but might help, depending on your purpose.

Implementing a docs search for multiple docs sites

We have many different documentation sites and I would like to search a keyword across all of these sites. How can I do that?
I already thought about implementing a simple web scraper, but this seems like a very ugly solution.
An alternative may be to use Elasticsearch and somehow point it to the different doc repos.
Are there better suggestions?
Algolia is the absolute best solution that I can think of. There's also Typesense and Meilisearch of course.
Algolia is meant specifically for situations like yours, so it even comes with a crawler.
https://www.algolia.com/products/search-and-discovery/crawler/
https://www.algolia.com/
https://typesense.org/
https://www.meilisearch.com/
Here's a fun page comparing them (probably a little biased in Typesense's favor)
https://typesense.org/typesense-vs-algolia-vs-elasticsearch-vs-meilisearch/
Here are some example sites that use Algolia Search
https://developers.cloudflare.com/
https://getbootstrap.com/docs/5.1/getting-started/introduction/
https://reactjs.org/
https://hn.algolia.com/
If you personally are just trying to search for a keyword, as long as they're indexed by Google, you can always search with the format site:{domain} "keyword"
You can checkout Meilisearch for your use case. Meilisearch is a Rust based and open sourced search engine.
Meilisearch comes with a document scraper tool ( https://github.com/meilisearch/docs-scraper ) that can scrape content and then also index it.
While using it you need to define what exact content you are searching for in the configuration file for the scraper tool. And then you can run the tool using Docker.

Using d3.js, mongoose, mongoDB, express properly

I'm really new to node.js and I've been reading a lot of tutorials and documentation on node.js, mongoose, mongoDB, Express, etc and I feel I'm still not getting something.
I want to make a website where data is generated by querying mongoDB and then results are returned to browser where it is visualized in d3.js.
I currently have a graph in d3 as a separate JS file (jdriver.js) called in the head of my jade file. My jdriver.js file is very self-contained in that it generates all the buttons, filters, sliders, etc.). However I'm not sure how I could go about, say if I want to apply a filter -> query mongodb -> have mongodb return a JSON data file -> redraws with new data.
And then how to fit all of that within the framework provided by Express?
Would someone be as kind to either point me to some sources or help me out?
Thanks so much.

Node.js + MongoDB: Generating shorter ID

I would like to create forum script with Node.js and MongoDB, but I have a problem with IDs which are pretty long in Mongo's case. I was already searching for solution, but I didn't find anything except the posts in which is written that I need to create ID's myself. I know more about PHP and MySQL, but I need Node for some realtime application in addition of forum. I would use generated ID for identifyng forum post, and next to it it would be thread's title - like this: address.domain/1/my-new-thread.
What do you recommend me?
I've used mongoose-pureautoinc and it works without problems.

What's a good node.js / mongoose form builder?

From using other frameworks I've gotten used to not building out and mapping forms to db objects manually. Since using node.js and mongoose. I'm looking for a form builder that allows the following:
automatically maps mongoose objects to form fields
handles both 'new' and 'update' use cases
allows class injection around form fields for styling
includes validation
allows one to add custom fields
Does anyone know of any such form builders for node.js, express, mongoose?
I haven't used it, or looked at it in depth, but https://github.com/oJshua/mongoose-forms looks like it may be of interest.
I know this is kind of old discussion but I just wanted to recommend checking out Formage (npm: formage)
https://github.com/Empeeric/formage
Setup is easy and straightforward. You can check it out in matter of minutes and hopefully this can help you.

Resources