Creating CouchDB 3.0 indexes.
This commit is contained in:
parent
dfa2881f1c
commit
03ef141297
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (doc._id.startsWith("ro_")) {
|
||||
idx(doc)
|
||||
if (doc._attachments) {
|
||||
for (let i in Object.keys(doc._attachments)) {
|
||||
ret.attachment("default", i)
|
||||
}
|
||||
}
|
||||
return ret
|
||||
}.toString(),
|
||||
},
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue