mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-19 23:00:13 +00:00
adapter tweaks
Signed-off-by: Andrey Platov <andrey@hardcoreeng.com>
This commit is contained in:
parent
2a010b5311
commit
8041336a84
@ -9005,7 +9005,7 @@ packages:
|
|||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
file:projects/elastic.tgz_6c259fadfeb3a4b20890aefe87070b8b:
|
file:projects/elastic.tgz_6c259fadfeb3a4b20890aefe87070b8b:
|
||||||
resolution: {integrity: sha512-TJMFjRCKTFiVvTUmHZXH2Z6dFAqMiQiXrvRr33eIqL8/x3a8a3qXGfcoXUoC1tjPUPOLqU9lqxTcXBJDLPwKrg==, tarball: file:projects/elastic.tgz}
|
resolution: {integrity: sha512-ywnrb5JlC7rhYSRd+y+/YNf4qa61yvKdCuNb/ziAhTvk12tMUjUP/Hsek+HU2G74wsnF9CPq485JMfPmj+yWXQ==, tarball: file:projects/elastic.tgz}
|
||||||
id: file:projects/elastic.tgz
|
id: file:projects/elastic.tgz
|
||||||
name: '@rush-temp/elastic'
|
name: '@rush-temp/elastic'
|
||||||
version: 0.0.0
|
version: 0.0.0
|
||||||
@ -9017,7 +9017,11 @@ packages:
|
|||||||
eslint-plugin-import: 2.23.4_eslint@7.32.0
|
eslint-plugin-import: 2.23.4_eslint@7.32.0
|
||||||
eslint-plugin-node: 11.1.0_eslint@7.32.0
|
eslint-plugin-node: 11.1.0_eslint@7.32.0
|
||||||
eslint-plugin-promise: 4.3.1
|
eslint-plugin-promise: 4.3.1
|
||||||
|
ts-node: 10.2.1_typescript@4.3.5
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
|
- '@swc/core'
|
||||||
|
- '@swc/wasm'
|
||||||
|
- '@types/node'
|
||||||
- '@typescript-eslint/parser'
|
- '@typescript-eslint/parser'
|
||||||
- supports-color
|
- supports-color
|
||||||
- typescript
|
- typescript
|
||||||
@ -9576,7 +9580,7 @@ packages:
|
|||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
file:projects/server.tgz_6c259fadfeb3a4b20890aefe87070b8b:
|
file:projects/server.tgz_6c259fadfeb3a4b20890aefe87070b8b:
|
||||||
resolution: {integrity: sha512-IXKKQtFZQA5Vw1Asc9H0qvs+4iwYCSXt8ozTaZ55xEg5CeMO9mE8sAVbTWA6TxP/4T+HRQMbzrI7LtwPgWI9xw==, tarball: file:projects/server.tgz}
|
resolution: {integrity: sha512-6XfixxRO1uisszjaBtMFoQCCvv2zWAknPVz3ZmES4q/keIWZuDDP667FpDMJ9maBB1AN7ImI9VBMXNbXDlVUuA==, tarball: file:projects/server.tgz}
|
||||||
id: file:projects/server.tgz
|
id: file:projects/server.tgz
|
||||||
name: '@rush-temp/server'
|
name: '@rush-temp/server'
|
||||||
version: 0.0.0
|
version: 0.0.0
|
||||||
@ -9841,7 +9845,7 @@ packages:
|
|||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
file:projects/workspace.tgz_6c259fadfeb3a4b20890aefe87070b8b:
|
file:projects/workspace.tgz_6c259fadfeb3a4b20890aefe87070b8b:
|
||||||
resolution: {integrity: sha512-LyUaHX4Kqn0fMCMfSsN4nIqIFtRzbRruDdSv5bfyefDF4WUfrYUdy8IUwuWuwmq5NTr49jLg9oLCyAJZ059Ong==, tarball: file:projects/workspace.tgz}
|
resolution: {integrity: sha512-q2/1LqGkYRwsMNbjDjy4ngJlBDAefFWXuEdVyIN0DyBjmBibnEVZuQayjBh5O7xUQYKlT0A7TdVn99hpIwixOA==, tarball: file:projects/workspace.tgz}
|
||||||
id: file:projects/workspace.tgz
|
id: file:projects/workspace.tgz
|
||||||
name: '@rush-temp/workspace'
|
name: '@rush-temp/workspace'
|
||||||
version: 0.0.0
|
version: 0.0.0
|
||||||
@ -9854,10 +9858,11 @@ packages:
|
|||||||
eslint-plugin-node: 11.1.0_eslint@7.32.0
|
eslint-plugin-node: 11.1.0_eslint@7.32.0
|
||||||
eslint-plugin-promise: 4.3.1
|
eslint-plugin-promise: 4.3.1
|
||||||
mongodb: 4.1.0
|
mongodb: 4.1.0
|
||||||
ts-node: 10.2.1_f50b86b1778cd2aa4e5405c08bb39559
|
ts-node: 10.2.1_typescript@4.3.5
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- '@swc/core'
|
- '@swc/core'
|
||||||
- '@swc/wasm'
|
- '@swc/wasm'
|
||||||
|
- '@types/node'
|
||||||
- '@typescript-eslint/parser'
|
- '@typescript-eslint/parser'
|
||||||
- supports-color
|
- supports-color
|
||||||
- typescript
|
- typescript
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
"author": "Anticrm Platform Contributors",
|
"author": "Anticrm Platform Contributors",
|
||||||
"license": "EPL-2.0",
|
"license": "EPL-2.0",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
"init": "ts-node src/__init.ts",
|
||||||
"build": "heft build",
|
"build": "heft build",
|
||||||
"lint:fix": "eslint --fix src"
|
"lint:fix": "eslint --fix src"
|
||||||
},
|
},
|
||||||
@ -15,7 +16,8 @@
|
|||||||
"eslint-plugin-import":"2",
|
"eslint-plugin-import":"2",
|
||||||
"eslint-plugin-promise":"4",
|
"eslint-plugin-promise":"4",
|
||||||
"eslint-plugin-node":"11",
|
"eslint-plugin-node":"11",
|
||||||
"eslint":"^7.32.0"
|
"eslint":"^7.32.0",
|
||||||
|
"ts-node":"^10.2.1"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@anticrm/core": "~0.6.11",
|
"@anticrm/core": "~0.6.11",
|
||||||
|
66
server/elastic/src/__init.ts
Normal file
66
server/elastic/src/__init.ts
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
//
|
||||||
|
// Copyright © 2020, 2021 Anticrm Platform Contributors.
|
||||||
|
// Copyright © 2021 Hardcore Engineering Inc.
|
||||||
|
//
|
||||||
|
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License. You may
|
||||||
|
// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
//
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
//
|
||||||
|
|
||||||
|
import { Client } from '@elastic/elasticsearch'
|
||||||
|
|
||||||
|
|
||||||
|
const url = process.env.ELASTIC_URL
|
||||||
|
if (url === undefined) {
|
||||||
|
console.error('please provide elastic url.')
|
||||||
|
process.exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
const client = new Client({node: 'http://45.32.149.163:9200/'})
|
||||||
|
|
||||||
|
client.ingest.putPipeline({
|
||||||
|
id: 'anticrm-pipeline',
|
||||||
|
body: {
|
||||||
|
"processors" : [
|
||||||
|
{ "attachment" : { "field" : "attachment" } },
|
||||||
|
{ "remove" : { "field" : "attachment" } }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.then(function () {
|
||||||
|
console.log("putPipeline Resolved");
|
||||||
|
})
|
||||||
|
.catch(function (error) {
|
||||||
|
console.log("putPipeline error: " + error)
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// // Create index
|
||||||
|
// client.create({index: 'pdfs', type: 'pdf', id: 'my-index-id',
|
||||||
|
// body: {description: 'Test pdf indexing'}
|
||||||
|
// })
|
||||||
|
// .then(function () {console.log("Index created");})
|
||||||
|
// .catch(function (error) {console.log(error);})
|
||||||
|
|
||||||
|
// var body = {
|
||||||
|
// anticrm_doc: {
|
||||||
|
// properties:{
|
||||||
|
// title : {"type" : "keyword", "index" : "false"},
|
||||||
|
// type : {"type" : "keyword", "index" : "false"},
|
||||||
|
// "attachment.pdf" : {"type" : "keyword"}
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// client.indices.putMapping({index:"pdfs", type:"pdf", body:body})
|
||||||
|
// .then((response) => {addPipeline()})
|
||||||
|
// .catch((error) => {console.log("putMapping error: " + error)})
|
@ -14,26 +14,25 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
//
|
//
|
||||||
|
|
||||||
// import type { Tx } from '@anticrm/core'
|
import type { Ref, Doc, Class, Obj, Account, Space } from '@anticrm/core'
|
||||||
|
import { createElasticAdapter } from '../adapter'
|
||||||
// import * as txJson from './model.tx.json'
|
|
||||||
|
|
||||||
// const txes = txJson as unknown as Tx[]
|
|
||||||
|
|
||||||
describe('client', () => {
|
describe('client', () => {
|
||||||
it('should create document', async () => {
|
it('should create document', async () => {
|
||||||
// const hierarchy = new Hierarchy()
|
const adapter = await createElasticAdapter('http://localhost:9200/', 'ws1')
|
||||||
// for (const tx of txes) hierarchy.tx(tx)
|
await adapter.index({
|
||||||
// const adapter = await createElasticAdapter(hierarchy, 'http://localhost:9200/', 'ws1')
|
id: 'doc1' as Ref<Doc>,
|
||||||
// const txFactory = new TxFactory(core.account.System)
|
_class: 'class1' as Ref<Class<Obj>>,
|
||||||
// const createTx = txFactory.createTxCreateDoc(core.class.Space, core.space.Model, {
|
modifiedBy: 'andrey' as Ref<Account>,
|
||||||
// name: 'name',
|
modifiedOn: 0,
|
||||||
// description: 'description',
|
space: 'space1' as Ref<Space>,
|
||||||
// private: false,
|
content: 'hey there!'
|
||||||
// members: []
|
})
|
||||||
|
const hits = await adapter.search({})
|
||||||
|
console.log(hits)
|
||||||
|
})
|
||||||
|
|
||||||
|
// it('should find document', async () => {
|
||||||
|
// const adapter = await createElasticAdapter('http://localhost:9200/', 'ws1')
|
||||||
// })
|
// })
|
||||||
// await adapter.tx(createTx)
|
|
||||||
// const spaces = await adapter.findAll(core.class.Space, {})
|
|
||||||
// console.log(spaces)
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -34,9 +34,8 @@ class ElasticAdapter implements FullTextAdapter {
|
|||||||
body: {
|
body: {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
const hits = result.body.hits.hits as []
|
const hits = result.body.hits.hits as any[]
|
||||||
console.log(hits)
|
return hits.map(hit => hit._source)
|
||||||
return []
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async index (doc: IndexedDoc): Promise<void> {
|
async index (doc: IndexedDoc): Promise<void> {
|
||||||
@ -45,7 +44,6 @@ class ElasticAdapter implements FullTextAdapter {
|
|||||||
type: '_doc',
|
type: '_doc',
|
||||||
body: doc
|
body: doc
|
||||||
})
|
})
|
||||||
console.log('indexing this thing: ', doc)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user