mirror of
https://github.com/hcengineering/platform.git
synced 2024-12-23 11:31:57 +03: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
|
||||
|
||||
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
|
||||
name: '@rush-temp/elastic'
|
||||
version: 0.0.0
|
||||
@ -9017,7 +9017,11 @@ packages:
|
||||
eslint-plugin-import: 2.23.4_eslint@7.32.0
|
||||
eslint-plugin-node: 11.1.0_eslint@7.32.0
|
||||
eslint-plugin-promise: 4.3.1
|
||||
ts-node: 10.2.1_typescript@4.3.5
|
||||
transitivePeerDependencies:
|
||||
- '@swc/core'
|
||||
- '@swc/wasm'
|
||||
- '@types/node'
|
||||
- '@typescript-eslint/parser'
|
||||
- supports-color
|
||||
- typescript
|
||||
@ -9576,7 +9580,7 @@ packages:
|
||||
dev: false
|
||||
|
||||
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
|
||||
name: '@rush-temp/server'
|
||||
version: 0.0.0
|
||||
@ -9841,7 +9845,7 @@ packages:
|
||||
dev: false
|
||||
|
||||
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
|
||||
name: '@rush-temp/workspace'
|
||||
version: 0.0.0
|
||||
@ -9854,10 +9858,11 @@ packages:
|
||||
eslint-plugin-node: 11.1.0_eslint@7.32.0
|
||||
eslint-plugin-promise: 4.3.1
|
||||
mongodb: 4.1.0
|
||||
ts-node: 10.2.1_f50b86b1778cd2aa4e5405c08bb39559
|
||||
ts-node: 10.2.1_typescript@4.3.5
|
||||
transitivePeerDependencies:
|
||||
- '@swc/core'
|
||||
- '@swc/wasm'
|
||||
- '@types/node'
|
||||
- '@typescript-eslint/parser'
|
||||
- supports-color
|
||||
- typescript
|
||||
|
@ -5,6 +5,7 @@
|
||||
"author": "Anticrm Platform Contributors",
|
||||
"license": "EPL-2.0",
|
||||
"scripts": {
|
||||
"init": "ts-node src/__init.ts",
|
||||
"build": "heft build",
|
||||
"lint:fix": "eslint --fix src"
|
||||
},
|
||||
@ -15,7 +16,8 @@
|
||||
"eslint-plugin-import":"2",
|
||||
"eslint-plugin-promise":"4",
|
||||
"eslint-plugin-node":"11",
|
||||
"eslint":"^7.32.0"
|
||||
"eslint":"^7.32.0",
|
||||
"ts-node":"^10.2.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@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.
|
||||
//
|
||||
|
||||
// import type { Tx } from '@anticrm/core'
|
||||
|
||||
// import * as txJson from './model.tx.json'
|
||||
|
||||
// const txes = txJson as unknown as Tx[]
|
||||
import type { Ref, Doc, Class, Obj, Account, Space } from '@anticrm/core'
|
||||
import { createElasticAdapter } from '../adapter'
|
||||
|
||||
describe('client', () => {
|
||||
it('should create document', async () => {
|
||||
// const hierarchy = new Hierarchy()
|
||||
// for (const tx of txes) hierarchy.tx(tx)
|
||||
// const adapter = await createElasticAdapter(hierarchy, 'http://localhost:9200/', 'ws1')
|
||||
// const txFactory = new TxFactory(core.account.System)
|
||||
// const createTx = txFactory.createTxCreateDoc(core.class.Space, core.space.Model, {
|
||||
// name: 'name',
|
||||
// description: 'description',
|
||||
// private: false,
|
||||
// members: []
|
||||
const adapter = await createElasticAdapter('http://localhost:9200/', 'ws1')
|
||||
await adapter.index({
|
||||
id: 'doc1' as Ref<Doc>,
|
||||
_class: 'class1' as Ref<Class<Obj>>,
|
||||
modifiedBy: 'andrey' as Ref<Account>,
|
||||
modifiedOn: 0,
|
||||
space: 'space1' as Ref<Space>,
|
||||
content: 'hey there!'
|
||||
})
|
||||
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: {
|
||||
}
|
||||
})
|
||||
const hits = result.body.hits.hits as []
|
||||
console.log(hits)
|
||||
return []
|
||||
const hits = result.body.hits.hits as any[]
|
||||
return hits.map(hit => hit._source)
|
||||
}
|
||||
|
||||
async index (doc: IndexedDoc): Promise<void> {
|
||||
@ -45,7 +44,6 @@ class ElasticAdapter implements FullTextAdapter {
|
||||
type: '_doc',
|
||||
body: doc
|
||||
})
|
||||
console.log('indexing this thing: ', doc)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user