Creating CouchDB 3.0 indexes.
This commit is contained in:
parent
24c523faad
commit
c51cf423e3
|
@ -34,37 +34,17 @@ services:
|
||||||
- minio-service
|
- minio-service
|
||||||
- couchdb-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:
|
couchdb-service:
|
||||||
container_name: budi-couchdb-dev
|
container_name: budi-couchdb-dev
|
||||||
restart: always
|
restart: always
|
||||||
build:
|
image: ibmcom/couchdb3
|
||||||
context: couch
|
|
||||||
dockerfile: Dockerfile
|
|
||||||
environment:
|
environment:
|
||||||
- COUCHDB_PASSWORD=${COUCH_DB_PASSWORD}
|
- COUCHDB_PASSWORD=${COUCH_DB_PASSWORD}
|
||||||
- COUCHDB_USER=${COUCH_DB_USER}
|
- COUCHDB_USER=${COUCH_DB_USER}
|
||||||
ports:
|
ports:
|
||||||
- "${COUCH_DB_PORT}:5984"
|
- "${COUCH_DB_PORT}:5984"
|
||||||
volumes:
|
volumes:
|
||||||
- couchdb_data:/opt/couchdb/data
|
- couchdb3_data:/opt/couchdb/data
|
||||||
# networks:
|
|
||||||
# dbs:
|
|
||||||
# aliases:
|
|
||||||
# - couchdb
|
|
||||||
|
|
||||||
couch-init:
|
couch-init:
|
||||||
container_name: budi-couchdb-init-dev
|
container_name: budi-couchdb-init-dev
|
||||||
|
@ -84,16 +64,10 @@ services:
|
||||||
volumes:
|
volumes:
|
||||||
- redis_data:/data
|
- redis_data:/data
|
||||||
|
|
||||||
networks:
|
|
||||||
dbs:
|
|
||||||
driver: bridge
|
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
couchdb_data:
|
couchdb3_data:
|
||||||
driver: local
|
driver: local
|
||||||
minio_data:
|
minio_data:
|
||||||
driver: local
|
driver: local
|
||||||
redis_data:
|
redis_data:
|
||||||
driver: local
|
driver: local
|
||||||
couchdb_lucene:
|
|
||||||
driver: local
|
|
||||||
|
|
|
@ -18,6 +18,5 @@ APP_PORT=4002
|
||||||
WORKER_PORT=4003
|
WORKER_PORT=4003
|
||||||
MINIO_PORT=4004
|
MINIO_PORT=4004
|
||||||
COUCH_DB_PORT=4005
|
COUCH_DB_PORT=4005
|
||||||
COUCH_LUCENE_PORT=4006
|
|
||||||
REDIS_PORT=6379
|
REDIS_PORT=6379
|
||||||
BUDIBASE_ENVIRONMENT=PRODUCTION
|
BUDIBASE_ENVIRONMENT=PRODUCTION
|
||||||
|
|
|
@ -76,33 +76,25 @@ exports.createRoutingView = async appId => {
|
||||||
exports.createFulltextSearchIndex = async appId => {
|
exports.createFulltextSearchIndex = async appId => {
|
||||||
const db = new CouchDB(appId)
|
const db = new CouchDB(appId)
|
||||||
const designDoc = await db.get("_design/database")
|
const designDoc = await db.get("_design/database")
|
||||||
designDoc.fulltext = {
|
designDoc.indexes = {
|
||||||
everything: {
|
rows: {
|
||||||
index: function(doc) {
|
index: function(doc) {
|
||||||
let ret = new Document()
|
// eslint-disable-next-line no-undef
|
||||||
|
index("id", doc._id)
|
||||||
function idx(obj) {
|
function idx(obj, prev = "") {
|
||||||
for (let key of Object.keys(obj)) {
|
for (let key of Object.keys(obj)) {
|
||||||
switch (typeof obj[key]) {
|
let prevKey = prev !== "" ? `${prev}.${key}` : key
|
||||||
case "object":
|
if (typeof obj[key] !== "object") {
|
||||||
idx(obj[key])
|
// eslint-disable-next-line no-undef
|
||||||
break
|
index(prevKey, obj[key], { store: true })
|
||||||
case "function":
|
} else {
|
||||||
break
|
idx(obj[key], prevKey)
|
||||||
default:
|
|
||||||
ret.add(obj[key])
|
|
||||||
break
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (doc._id.startsWith("ro_")) {
|
||||||
idx(doc)
|
idx(doc)
|
||||||
if (doc._attachments) {
|
|
||||||
for (let i in Object.keys(doc._attachments)) {
|
|
||||||
ret.attachment("default", i)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return ret
|
|
||||||
}.toString(),
|
}.toString(),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue