Cloudant: Database Search

I have documents in two different databases: fruits, vegetables. It’s easier for me to store databases separately.

Now suppose I want my user to search for any combination of these databases. Would it work if I ran the same query in three databases and combined the result. That is: does the order field have absolute value in the results, or does it relate to other results? For instance:

Run my db fruit query:

 { total_rows: 2, bookmark: "xxx", rows: [ { id: "Apple", order: [ 2, 220 ], fields: { title: "Apple" } }, { id: "pear", order: [ 1, 4223 ], fields: { title: "Pear" } } } 

Run my query in the vegetable database:

 { total_rows: 1, bookmark: "xxx", rows: [ { id: "brocolli", order: [ 1.5, 3000 ], fields: { title: "Brocolli" } } } 

Then, combining the results to create

 { total_rows: 2, bookmark: "xxx", rows: [ { id: "Apple", order: [ 2, 220 ], fields: { title: "Apple" } }, { id: "brocolli", order: [ 1.5, 3000 ], fields: { title: "Brocolli" } }, { id: "pear", order: [ 1, 4223 ], fields: { title: "Pear" } } } 

Will this work? Or is it better to just create a single foods database?

+1
source share
1 answer

Unable to perform joins between databases using CouchDB or Cloudant. You will need to either:

  • put all your data in one database and request that
  • have separate databases and replicate data from each to one database and request that
  • have separate databases and perform connection functionality at the level of your application

I added this question: How can I use my sql knowledge with Cloudant / CouchDB?

+1
source

Source: https://habr.com/ru/post/982549/


All Articles