I have several documents in my couchdb database. Followng is an example of it:
"company": [
"xyz",
"abcintl"
],
"usermentions": [
"Abce",
"Swat",
"axis"
],
I have a company name as my keyword. Let's say 'abcintl'. I want to emit a document who has 'abcintl' in company OR usermentions. If any of these attributes contain my keyword I want to emit that document.
Thanks,
If you want to find the documents that contain a certain keyword, just emit the company
and usermentions
array values.
function (doc) {
doc.company.forEach(function (company) {
emit(company);
});
doc.usermentions.forEach(function (mention) {
emit(mention);
});
}
Your view will include all the company/usermentions for each document. So you can query your view with key="abcintl"
, and you'll find all the document IDs that contain that value in either array.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.