1
0
Fork 0
mirror of synced 2024-06-27 18:40:42 +12:00

Creating CouchDB 3.0 indexes.

This commit is contained in:
mike12345567 2021-03-25 19:12:17 +00:00
parent dfa2881f1c
commit 03ef141297
3 changed files with 16 additions and 51 deletions

View file

@ -34,37 +34,17 @@ services:
- minio-service
- couchdb-service
couchdb-lucene:
container_name: budi-couchdb-lucene-dev
build:
context: lucene
dockerfile: Dockerfile
ports:
- "${COUCH_LUCENE_PORT}:5985"
volumes:
- couchdb_lucene:/opt/couchdb-lucene
networks:
dbs:
aliases:
- couchdb-lucene
couchdb-service:
container_name: budi-couchdb-dev
restart: always
build:
context: couch
dockerfile: Dockerfile
image: ibmcom/couchdb3
environment:
- COUCHDB_PASSWORD=${COUCH_DB_PASSWORD}
- COUCHDB_USER=${COUCH_DB_USER}
ports:
- "${COUCH_DB_PORT}:5984"
volumes:
- couchdb_data:/opt/couchdb/data
# networks:
# dbs:
# aliases:
# - couchdb
- couchdb3_data:/opt/couchdb/data
couch-init:
container_name: budi-couchdb-init-dev
@ -84,16 +64,10 @@ services:
volumes:
- redis_data:/data
networks:
dbs:
driver: bridge
volumes:
couchdb_data:
couchdb3_data:
driver: local
minio_data:
driver: local
redis_data:
driver: local
couchdb_lucene:
driver: local

View file

@ -18,6 +18,5 @@ APP_PORT=4002
WORKER_PORT=4003
MINIO_PORT=4004
COUCH_DB_PORT=4005
COUCH_LUCENE_PORT=4006
REDIS_PORT=6379
BUDIBASE_ENVIRONMENT=PRODUCTION

View file

@ -76,33 +76,25 @@ exports.createRoutingView = async appId => {
exports.createFulltextSearchIndex = async appId => {
const db = new CouchDB(appId)
const designDoc = await db.get("_design/database")
designDoc.fulltext = {
everything: {
designDoc.indexes = {
rows: {
index: function(doc) {
let ret = new Document()
function idx(obj) {
// eslint-disable-next-line no-undef
index("id", doc._id)
function idx(obj, prev = "") {
for (let key of Object.keys(obj)) {
switch (typeof obj[key]) {
case "object":
idx(obj[key])
break
case "function":
break
default:
ret.add(obj[key])
break
let prevKey = prev !== "" ? `${prev}.${key}` : key
if (typeof obj[key] !== "object") {
// eslint-disable-next-line no-undef
index(prevKey, obj[key], { store: true })
} else {
idx(obj[key], prevKey)
}
}
}
idx(doc)
if (doc._attachments) {
for (let i in Object.keys(doc._attachments)) {
ret.attachment("default", i)
}
if (doc._id.startsWith("ro_")) {
idx(doc)
}
return ret
}.toString(),
},
}