Elasticsearch using my PostgresSQL database - node.js

By default Elasticsearch seems to query its own database in the indexes defined during the search.
Is it possible that Elasticsearch is not querying its database but mine in PostgresSql?

No.
Elasticsearch is a database on its own rights, it's not an interface/middleman for other backends.
If you want to conditionally query different databases, you need to implement that logic at application level.

Related

Query another database using Prisma

I am already using Prisma as an ORM for a Postgres DB. I need to run a simple raw query on a SQL Server DB. I do not need to use any of the ORM features like the Prisma schema, migrations, etc. Is it possible to do with Prisma? I am trying to minimize dependencies.
Look at this part of the documentation and see if it meets your request.
https://www.prisma.io/client
prima raw query
You would need to create two PrismaClient Instances, one for the PostgresDB and other for SQL Server.
Here's a GitHub Issue on how you can implement it: #2443

Which is the best way to do database search on mean stack

I am using mongodb to store items for an auction site
I want to enable fuzzy searching.
Should I query for 1000 results with no parameters then use a js library like fuse.js
Or should I rely on mongodb $regex alone to do the query?
mongodb isn't a great choice for a problem like this. There are lots of great text search utilities available, the most prominent these days being elasticsearch. You'd continue to store your data in mongodb, but you'd keep an elasticsearch instance synced to the mongodb database and perform your searches against elasticsearch. Mongoosastic is a good way to write to both concurrently or Transporter can be used shift the synchronization away from your database persistence flow.
Mongoosastic example:
https://blog.cloudboost.io/sync-mongo-with-elastic-and-save-months-of-development-time-and-cost-d281e0ca8fe4
Some other ways to sync including Transporter: https://code.likeagirl.io/5-different-ways-to-synchronize-data-from-mongodb-to-elasticsearch-d8456b83d44f

Migrating data from solr to elastic search

What would be the best way to migrate Solr cores to elastic search indices ?
The solr-river-plugin (https://github.com/javanna/elasticsearch-river-solr) is deprecated.
There's a nice adhoc Python tool made with love by the nice folks at OpenSource Connections that you can use to do this:
https://github.com/o19s/solr-to-es
Simply
./solr-to-es solr_url elasticsearch_url elasticsearch_index doc_type
For instance, the command below will page through all documents on the local Solr node, named node, and submit them to the local Elasticsearch server in the index my_index with a document type of my_type.
./solr-to-es.py localhost:8983/solr/node localhost:9200 my_index my_type

Retrieving data from couchDB

I am new to couchDB but have a good experience working with relational databases. Can anyone tell how to connect to couchDB database and retrieve the data stored in it. I am giving an example in relational database and i need help regarding how to do similar task in couchDB.In mysql we use a connector to get connected to the database and the for example we give "select username from tablename where password="abc" ".
CouchDB talks HTTP and JSON, then you can use any HTTP client and JSON parser/generator. You can find a nice introduction in The Definitive Guide.
Try this URL: http://localhost:5984/_utils/, it will open FUTON editor.
CouchDB is a NOSQL database. So it works using HTTP requests (url based). Data that is stored in couchDB is in the form of JSON documents, so there is no concept of tables. In short, database in SQL represent database in couchDB and the rows in a table of SQL represent Documents in couchDB.
Coming back to your question, to retrieve data from couchDB, there is a concept called views which uses Map and Reduce functions (which are JavaScript functions). Using these views couchDB indexes your search function spanning through the complete database (includes all documents), so you need to write a Map function specifying the condition to be used to search. Here's an example -
function(doc) {
if (doc.password) {
emit(doc.username, doc);
}
}
The above example is a simple Map function. Search for the documents of the database where there is a password and return the usernames from all the documents in the database. Password input value (in this case "abc") should be specified in the query string that you will be sending out to couchDB URL. Now, you might ask where is the database specified to search for? I said that we have to create views in order to search. These views are stored in that particular database where you want to search. So, if you want to search a database with name "User_Credentials", then create a view in the "User_Credentials" with the above Map function. More details on how it can be done can be found here: CouchDB Guide to Views

Indexing a CouchDB view with ElasticSearch

Using the CouchDB river, it is possible to index CouchDB databases.
Is it also possible to index a CouchDB view with Elastic Search?
Not yet. See https://github.com/elasticsearch/elasticsearch-river-couchdb/pull/2
BTW you can checkout my pull request, build it and start to query views...

Resources